diff --git a/.vitepress/beforeBuild.mjs b/.vitepress/beforeBuild.mjs index 2bdc1e6..748b06d 100644 --- a/.vitepress/beforeBuild.mjs +++ b/.vitepress/beforeBuild.mjs @@ -84,7 +84,7 @@ readdir(folder) items.map((item) => writeFile(resolve(folder, item.file), buildFrontMatter(item) + '\r\n' + item.content)) ).then(() => { if (breakBuildInfo.length) { - console.error(`WARNING: [${breakBuildInfo}] build failed, exiting.`) + console.error(`ERROR: [${breakBuildInfo}] build failed, exiting.`) exit(1) } }) diff --git a/.vitepress/config.mts b/.vitepress/config.mts index bf9a801..c06344f 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -1,14 +1,16 @@ /// -import { defineConfig } from "vitepress" +import { defineConfig, type HeadConfig } from "vitepress" import svgLoader from 'vite-svg-loader' // https://vitepress.dev/reference/site-config -export default defineConfig({ - title: "Maicss", - description: "Miacss' website pyqt 中文 教程 pyqt5 pyqt6", - head: [ - ["link", { rel: "icon", href: "/favicon.ico" }], - ["link", { rel: "manifest", href: "/site.webmanifest" }], + +const head:HeadConfig[] = [ + ["link", { rel: "icon", href: "/favicon.ico" }], + ["link", { rel: "manifest", href: "/site.webmanifest" }], +] + +if (process.env.NODE_ENV === 'production') { + head.push( [ "script", { @@ -16,6 +18,8 @@ export default defineConfig({ src: "https://www.googletagmanager.com/gtag/js?id=G-7KBNJR8LJ3", }, ], + ) + head.push( [ "script", {}, @@ -24,6 +28,9 @@ export default defineConfig({ gtag('js', new Date()); gtag('config', 'G-7KBNJR8LJ3');`, ], + ) + + head.push( [ "script", {}, @@ -35,7 +42,13 @@ export default defineConfig({ s.parentNode.insertBefore(hm, s); })();`, ], - ], + ) +} + +export default defineConfig({ + title: "Maicss", + description: "Miacss' website pyqt 中文 教程 pyqt5 pyqt6", + head, srcDir: "./pages", lang: "zh-CN", cleanUrls: true, @@ -125,10 +138,22 @@ export default defineConfig({ sitemap: { hostname: "https://maicss.com", }, + markdown: { + image: { + lazyLoading: true + } + }, vite: { plugins: [svgLoader({ defaultImport: 'component' - })] + })], + build: { + rollupOptions: { + output: { + assetFileNames: `assets/[name].[ext]` + } + } + } }, // buildEnd: genFeed }); diff --git a/.vitepress/theme/BlogIndex.vue b/.vitepress/theme/BlogIndex.vue index 7841749..77bdfa4 100644 --- a/.vitepress/theme/BlogIndex.vue +++ b/.vitepress/theme/BlogIndex.vue @@ -34,7 +34,7 @@ const changePage = (page:number|'prev'|'next') => {