mirror of https://github.com/YunYouJun/valaxy
fix: use post process for magic not closed tag html/> ml> l>
This commit is contained in:
parent
147072f419
commit
69a19697c8
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
title: 图片测试
|
||||
---
|
||||
|
||||

|
||||
|
||||

|
|
@ -10,9 +10,10 @@ categories:
|
|||
::: tip
|
||||
**约定大于配置**
|
||||
|
||||
插件与主题类似,但做的事情更少。
|
||||
- 插件与主题类似,但做的事情更少。
|
||||
- 一个站点只能使用一个主题,但可以使用多个插件。
|
||||
- Addon 无需预编译,直接发布源文件即可。
|
||||
|
||||
一个站点只能使用一个主题,但可以使用多个插件。
|
||||
:::
|
||||
|
||||
- [ ] `App.vue` 如果插件作者希望插件被使用时立刻全局挂载,可以将内容放置于 `valaxy-addon-<name>/App.vue` 中,并设置 `package.json` 中 `global: true`。
|
||||
|
|
|
@ -16,6 +16,7 @@ end: false
|
|||
- [ ] Debug component.
|
||||
- [x] local search
|
||||
- [ ] algolia search for valaxy-theme-press
|
||||
- [ ] Image preview by [lightGallery](https://www.lightgalleryjs.com/docs/vue/)
|
||||
|
||||
## Dev
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ Valaxy 与 Vite/Vue 的生态完全兼容,因此你在编写主题时,可以
|
|||
|
||||
:::
|
||||
|
||||
Valaxy 主题无需预编译,直接发布源文件即可。
|
||||
|
||||
撰写中...
|
||||
|
||||
## APIs
|
||||
|
|
|
@ -89,7 +89,7 @@ export default defineValaxyConfig<PressTheme.Config>({
|
|||
],
|
||||
|
||||
footer: {
|
||||
message: `Released under the MIT License. (<a href="https://github.com/YunYouJun/valaxy/commit/${commitRef}" target="_blank" alt=${commitRef}>${commitRef})</a>`,
|
||||
message: `Released under the MIT License. (<a href="https://github.com/YunYouJun/valaxy/commit/${commitRef}" target="_blank" alt=${commitRef}>${commitRef}</a>)`,
|
||||
copyright:
|
||||
'Copyright © 2022-present <a href="https://github.com/YunYouJun" target="_blank">YunYouJun</a> & <a href="https://github.com/YunYouJun/valaxy/graphs/contributors" target="_blank">Valaxy Contributors</a>',
|
||||
},
|
||||
|
|
|
@ -8,10 +8,8 @@ defineProps<{
|
|||
|
||||
<template>
|
||||
<div class="inline-flex" text="sm" py="1">
|
||||
<YunPostCategories :categories="frontmatter.categories" />
|
||||
<YunPostCategories v-if="frontmatter.categories" :categories="frontmatter.categories" />
|
||||
<span v-if="frontmatter.categories && frontmatter.tags" mx="2">-</span>
|
||||
<template v-if="frontmatter.tags">
|
||||
<YunPostTags :tags="frontmatter.tags" />
|
||||
</template>
|
||||
<YunPostTags v-if="frontmatter.tags" :tags="frontmatter.tags" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- head -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="__ENTRY__"></script>
|
||||
<!-- body -->
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import { resolve } from 'path'
|
||||
import type { InlineConfig } from 'vite'
|
||||
import { mergeConfig as mergeViteConfig, build as viteBuild } from 'vite'
|
||||
import { build as viteSsgBuild } from 'vite-ssg/node'
|
||||
import generateSitemap from 'vite-ssg-sitemap'
|
||||
|
||||
import fs from 'fs-extra'
|
||||
import consola from 'consola'
|
||||
import type { ResolvedValaxyOptions } from './options'
|
||||
import { ViteValaxyPlugins } from './plugins/preset'
|
||||
// import { logger } from './logger'
|
||||
|
||||
export async function build(
|
||||
options: ResolvedValaxyOptions,
|
||||
|
@ -45,3 +49,24 @@ export async function ssgBuild(
|
|||
|
||||
await viteSsgBuild({}, inlineConfig)
|
||||
}
|
||||
|
||||
/**
|
||||
* post process for ssg fix extra string like `/html>` `ml>` `l>`
|
||||
* todo find why
|
||||
* @param options
|
||||
*/
|
||||
export const postProcessForSSG = async (options: ResolvedValaxyOptions) => {
|
||||
const { userRoot } = options
|
||||
const indexPath = resolve(userRoot, 'dist/index.html')
|
||||
if (fs.existsSync(indexPath)) {
|
||||
consola.info('post process for ssg...')
|
||||
|
||||
const indexFile = await fs.readFile(indexPath, 'utf-8')
|
||||
// fix incomplete index.html (with extra /html>) generated by vite-ssg
|
||||
const htmlTag = '</html>'
|
||||
if (!indexFile.endsWith(htmlTag)) {
|
||||
const htmlTagStart = indexFile.lastIndexOf(htmlTag)
|
||||
await fs.writeFile(indexPath, indexFile.slice(0, htmlTagStart + htmlTag.length), 'utf-8')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { resolveOptions } from './options'
|
|||
import { bindShortcut, initServer, printInfo } from './utils/cli'
|
||||
|
||||
// build
|
||||
import { build, ssgBuild } from './build'
|
||||
import { build, postProcessForSSG, ssgBuild } from './build'
|
||||
// rss
|
||||
import { build as rssBuild } from './rss'
|
||||
import { getIndexHtml, mergeViteConfigs } from './common'
|
||||
|
@ -179,6 +179,7 @@ cli.command(
|
|||
|
||||
try {
|
||||
await ssgBuild(options, viteConfig)
|
||||
await postProcessForSSG(options)
|
||||
}
|
||||
catch (e) {
|
||||
consola.error('[vite-ssg] An internal error occurred.')
|
||||
|
@ -190,6 +191,9 @@ cli.command(
|
|||
await build(options, viteConfig)
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
finally {
|
||||
// await fs.unlink(indexPath)
|
||||
await fs.copyFile(templatePath, indexPath)
|
||||
|
|
|
@ -50,6 +50,9 @@ export async function getIndexHtml({ clientRoot, themeRoot, userRoot, config }:
|
|||
let head = ''
|
||||
let body = ''
|
||||
|
||||
if (config.siteConfig.favicon)
|
||||
head += `<link rel="icon" href="${config.siteConfig.favicon}">`
|
||||
|
||||
const roots = [userRoot, themeRoot]
|
||||
|
||||
if (config.siteConfig.mode === 'auto') {
|
||||
|
|
|
@ -14,14 +14,17 @@ import { getIndexHtml } from '../common'
|
|||
const clientDeps = [
|
||||
'@vueuse/head',
|
||||
'@vueuse/integrations/useFuse',
|
||||
'body-scroll-lock',
|
||||
'dayjs',
|
||||
'katex',
|
||||
'nprogress',
|
||||
'unocss',
|
||||
'vue',
|
||||
'vue-router',
|
||||
'dayjs',
|
||||
'nprogress',
|
||||
'katex',
|
||||
|
||||
// will may be addons
|
||||
'fuse.js',
|
||||
'body-scroll-lock',
|
||||
'medium-zoom',
|
||||
]
|
||||
|
||||
/**
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
"markdown-it-emoji": "^2.0.2",
|
||||
"markdown-it-table-of-contents": "^0.6.0",
|
||||
"markdown-it-task-lists": "^2.1.1",
|
||||
"medium-zoom": "^1.0.8",
|
||||
"nprogress": "^0.2.0",
|
||||
"open": "^8.4.0",
|
||||
"pascal-case": "^3.1.2",
|
||||
|
|
|
@ -154,6 +154,7 @@ importers:
|
|||
markdown-it-emoji: ^2.0.2
|
||||
markdown-it-table-of-contents: ^0.6.0
|
||||
markdown-it-task-lists: ^2.1.1
|
||||
medium-zoom: ^1.0.8
|
||||
nprogress: ^0.2.0
|
||||
open: ^8.4.0
|
||||
pascal-case: ^3.1.2
|
||||
|
@ -209,6 +210,7 @@ importers:
|
|||
markdown-it-emoji: 2.0.2
|
||||
markdown-it-table-of-contents: 0.6.0
|
||||
markdown-it-task-lists: 2.1.1
|
||||
medium-zoom: 1.0.8
|
||||
nprogress: 0.2.0
|
||||
open: 8.4.0
|
||||
pascal-case: 3.1.2
|
||||
|
@ -4952,6 +4954,10 @@ packages:
|
|||
engines: {node: '>= 0.6'}
|
||||
dev: true
|
||||
|
||||
/medium-zoom/1.0.8:
|
||||
resolution: {integrity: sha512-CjFVuFq/IfrdqesAXfg+hzlDKu6A2n80ZIq0Kl9kWjoHh9j1N9Uvk5X0/MmN0hOfm5F9YBswlClhcwnmtwz7gA==}
|
||||
dev: false
|
||||
|
||||
/merge-descriptors/1.0.1:
|
||||
resolution: {integrity: sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==}
|
||||
dev: true
|
||||
|
|
Loading…
Reference in New Issue