From b37e35000e5ce235830b76681fd082b9a844e9b5 Mon Sep 17 00:00:00 2001 From: GaoNeng-wWw Date: Sat, 23 Sep 2023 21:43:17 +0800 Subject: [PATCH] feat: menu --- app.vue | 11 ++- components/git-meta.vue | 54 +++++++++++++++ components/logo.vue | 12 ++++ nuxt.config.ts | 38 ++++++++--- package.json | 4 +- pages/[...slug].vue | 129 ----------------------------------- pages/index.vue | 23 +++++++ pages/posts/[...slug].vue | 60 ++++++++++++++++ scripts/useAllRouter.ts | 20 ------ scripts/usePreRenderRoute.ts | 17 +++++ server/tsconfig.json | 3 - 11 files changed, 206 insertions(+), 165 deletions(-) create mode 100644 components/git-meta.vue create mode 100644 components/logo.vue delete mode 100644 pages/[...slug].vue create mode 100644 pages/index.vue create mode 100644 pages/posts/[...slug].vue delete mode 100644 scripts/useAllRouter.ts create mode 100644 scripts/usePreRenderRoute.ts delete mode 100644 server/tsconfig.json diff --git a/app.vue b/app.vue index 07f9301..d2a2d64 100644 --- a/app.vue +++ b/app.vue @@ -1,7 +1,12 @@ diff --git a/components/git-meta.vue b/components/git-meta.vue new file mode 100644 index 0000000..4e7bfee --- /dev/null +++ b/components/git-meta.vue @@ -0,0 +1,54 @@ + + + \ No newline at end of file diff --git a/components/logo.vue b/components/logo.vue new file mode 100644 index 0000000..e4deeae --- /dev/null +++ b/components/logo.vue @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/nuxt.config.ts b/nuxt.config.ts index 05a22e2..a1e8d1b 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,23 +1,43 @@ +import usePreRenderRoute from "./scripts/usePreRenderRoute"; + export default defineNuxtConfig({ - devtools: { enabled: false }, + devtools: { enabled: true }, modules: [ '@nuxt/content', '@nuxtjs/tailwindcss' ], - css: ['@/assets/css/main.css'], + // css: ['@/assets/css/main.css'], nitro: { - preset: 'vercel' + preset: 'static', + prerender:{ + routes: [...usePreRenderRoute()], + }, + }, + experimental: { + externalVue: true, + payloadExtraction: true, + inlineSSRStyles: false, }, - vite: { + vite:{ build: { cssCodeSplit: true, cssMinify: true, - chunkSizeWarningLimit: 2000, - minify: true, + minify: 'terser', + terserOptions:{ + compress: { + drop_console: true, + drop_debugger: true, + dead_code: false, + }, + }, }, }, - experimental: { - externalVue: true, - payloadExtraction: true + app:{ + head:{ + htmlAttrs:{ + lang: 'zh-cn' + }, + title: 'Rescume Life', + } }, }) \ No newline at end of file diff --git a/package.json b/package.json index ea32740..f2d802f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "devDependencies": { "@nuxt/devtools": "latest", + "@nuxt/webpack-builder": "^3.7.3", "@tailwindcss/typography": "^0.5.10", "autoprefixer": "^10.4.15", "glob": "^10.3.4", @@ -20,6 +21,7 @@ }, "dependencies": { "@nuxt/content": "^2.8.2", - "@nuxtjs/tailwindcss": "^6.8.0" + "@nuxtjs/tailwindcss": "^6.8.0", + "@vueuse/core": "^10.4.1" } } diff --git a/pages/[...slug].vue b/pages/[...slug].vue deleted file mode 100644 index 32b23e3..0000000 --- a/pages/[...slug].vue +++ /dev/null @@ -1,129 +0,0 @@ - - - - - diff --git a/pages/index.vue b/pages/index.vue new file mode 100644 index 0000000..e379a7b --- /dev/null +++ b/pages/index.vue @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/pages/posts/[...slug].vue b/pages/posts/[...slug].vue new file mode 100644 index 0000000..b9bdd87 --- /dev/null +++ b/pages/posts/[...slug].vue @@ -0,0 +1,60 @@ + + + + + diff --git a/scripts/useAllRouter.ts b/scripts/useAllRouter.ts deleted file mode 100644 index ee07f84..0000000 --- a/scripts/useAllRouter.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {globSync} from 'glob'; - -function isIndex(path: string) { - return /index/.test(path); -} - -function normalizationData(paths: string[]) { - return paths.map((p) => p.replaceAll('\\', '/')).map((path) => { - const rawPath = path.replace(/content/gim, '').replace('.md', ''); - if (isIndex(rawPath)) { - return rawPath.replace('/index', '') - } - return rawPath; - }) -} - -export default function usePreRenderRoute() { - const res = globSync('content/**/*.md') - return normalizationData(res) -} diff --git a/scripts/usePreRenderRoute.ts b/scripts/usePreRenderRoute.ts new file mode 100644 index 0000000..b60ba4a --- /dev/null +++ b/scripts/usePreRenderRoute.ts @@ -0,0 +1,17 @@ +import {globSync, Glob} from 'glob'; +function isIndex(path: string){ + return /index/.test(path); +} +function normalizationData(paths: string[]){ + return paths.map((p) => p.replaceAll('\\', '/')).map((path) => { + const rawPath = path.replace(/content/gim, '/posts/').replace('.md', ''); + if (isIndex(rawPath)){ + return rawPath.replace('/index','') + } + return rawPath; + }) +} +export default function usePreRenderRoute(){ + const res = globSync('content/*.md') + return normalizationData(res) +} diff --git a/server/tsconfig.json b/server/tsconfig.json deleted file mode 100644 index b9ed69c..0000000 --- a/server/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../.nuxt/tsconfig.server.json" -}