fix: released ssg build error caused by root

This commit is contained in:
YunYouJun 2022-07-21 21:56:16 +08:00
parent bf76c66bb7
commit 9a2a9e2b11
18 changed files with 830 additions and 1162 deletions

View File

@ -1,6 +1,6 @@
{
"name": "yun-demo",
"slidev": {
"valaxy": {
"theme": "yun"
},
"scripts": {

3
demo/yun/template.html Normal file
View File

@ -0,0 +1,3 @@
<head>
asd
</head>

View File

@ -61,7 +61,7 @@ layout: album
## 自定义 index.html
新建 `index.html`,你可以在 `<head></head>``<body></body>` 全局地插入任意内容。
新建 `template.html`,你可以在 `<head></head>``<body></body>` 全局地插入任意内容。
譬如:

View File

@ -140,6 +140,26 @@ Documentation is being improved!
文档正在不断完善中!
:::
## Deploy {lang="en"}
## 部署 {lang="zh-CN"}
### GitHub Pages 自动部署
上传至 GitHub Repo打开 `Settings` -> `Pages`,选择 `gh-pages` 分支。
> `gh-pages` 已由 `.github/workflows/gh-pages.yml` 自动部署。
### 自行部署
```bash
# 构建打包
npm run build
# dist 文件夹为构建后的内容
```
可使用 [Netlify](https://www.netlify.com/)/[Vercel](https://vercel.com/)/[Render](https://render.com/)/[Cloudflare Pages](https://pages.cloudflare.com/) 等进行托管。
## Upgrade {lang="en"}
## 升级 {lang="zh-CN"}

View File

@ -61,6 +61,16 @@
"vue-tsc": "0.38.9",
"zx": "^7.0.7"
},
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [
"@algolia/client-search",
"@types/react",
"react",
"react-dom"
]
}
},
"lint-staged": {
"{packages,demo,scripts}/**/*.{js,ts,vue,json,yml}": [
"eslint --fix"

View File

@ -13,3 +13,5 @@ node_modules
*.log
components.d.ts
# use template.html
index.html

View File

@ -0,0 +1 @@
export * from '../composables'

View File

@ -0,0 +1 @@
export * from '../composables'

View File

@ -1,2 +1,4 @@
# ignore it
components.d.ts
# use template.html
index.html

View File

@ -0,0 +1,3 @@
<template>
<Layout />
</template>

View File

@ -0,0 +1,34 @@
<template>
<router-view v-slot="{ Component }">
<component :is="Component">
<template #main-header>
<slot name="main-header" />
</template>
<template #main-header-after>
<slot name="main-header-after" />
</template>
<template #main>
<slot name="main" />
</template>
<template #main-content>
<slot name="main-content" />
</template>
<template #main-content-after>
<slot name="main-content-after" />
</template>
<template #main-nav-before>
<slot name="main-nav-before" />
</template>
<template #main-nav-after>
<slot name="main-nav-after" />
</template>
<template #aside-custom>
<slot name="aside-custom" />
</template>
<template #footer>
<slot name="footer" />
</template>
</component>
</router-view>
</template>

View File

@ -0,0 +1,3 @@
<template>
<Layout />
</template>

View File

@ -1,7 +1,7 @@
import type { ViteSSGContext } from 'vite-ssg'
import type { Awaitable } from '@antfu/utils'
type AppContext = ViteSSGContext
export type AppContext = ViteSSGContext
export type AppSetup = (ctx: AppContext) => Awaitable<void>

View File

@ -151,10 +151,10 @@ cli.command(
)
// merge index.html
const templatePath = path.resolve(options.userRoot, 'template.html')
const indexPath = path.resolve(options.userRoot, 'index.html')
let originalIndexHTML: string | undefined
if (fs.existsSync(indexPath))
originalIndexHTML = await fs.readFile(indexPath, 'utf-8')
if (fs.existsSync(templatePath))
await fs.copyFile(templatePath, indexPath)
await fs.writeFile(indexPath, await getIndexHtml(options), 'utf-8')
try {
@ -175,10 +175,7 @@ cli.command(
}
}
finally {
if (originalIndexHTML != null)
await fs.writeFile(indexPath, originalIndexHTML, 'utf-8')
else
await fs.unlink(indexPath)
await fs.unlink(indexPath)
}
},
)

View File

@ -11,7 +11,9 @@
// loader, the raw HTML in headers will finally be parsed by Vue-loader.
// so that we can write HTML/Vue in the header. One exception is the HTML
// wrapped by <code>(markdown token: '`') tag.
import emojiData from 'markdown-it-emoji/lib/data/full.json'
// https://v8.dev/features/import-assertions esm
import emojiData from 'markdown-it-emoji/lib/data/full.json' assert { type: 'json' }
const parseEmojis = (str: string) => {
return str.replace(

View File

@ -1,8 +1,9 @@
import { dirname, join, resolve } from 'path'
import type { InlineConfig, Plugin } from 'vite'
import { mergeConfig } from 'vite'
import { mergeConfig, searchForWorkspaceRoot } from 'vite'
import isInstalledGlobally from 'is-installed-globally'
import fs from 'fs-extra'
import { uniq } from '@antfu/utils'
import type { ResolvedValaxyOptions } from '../options'
import { resolveImportPath, toAtFS } from '../utils'
import { getIndexHtml } from '../common'
@ -53,13 +54,12 @@ export function createConfigPlugin(options: ResolvedValaxyOptions): Plugin {
server: {
fs: {
allow: [
// not need to search workspace root
options.clientRoot,
options.themeRoot,
options.userRoot,
allow: uniq([
searchForWorkspaceRoot(options.clientRoot),
searchForWorkspaceRoot(options.themeRoot),
searchForWorkspaceRoot(options.userRoot),
dirname(resolveImportPath('katex/package.json', true)),
],
]),
},
},
}

View File

@ -22,11 +22,7 @@
"import": "./dist/node/index.mjs"
},
"./client/*": "./client/*",
"./client": {
"types": "./dist/client/index.d.ts",
"require": "./dist/client/index.js",
"import": "./dist/client/index.mjs"
},
"./client": "./client/index.ts",
"./node": {
"types": "./dist/node/index.d.ts",
"require": "./dist/node/index.js",
@ -78,6 +74,7 @@
"global-dirs": "^3.0.0",
"gray-matter": "^4.0.3",
"is-installed-globally": "^0.4.0",
"jiti": "^1.14.0",
"katex": "^0.16.0",
"kolorist": "^1.5.1",
"lru-cache": "^7.13.1",

File diff suppressed because it is too large Load Diff