From 63aa495d8b27ddb43e97a7586eb8e5ed7104f2d7 Mon Sep 17 00:00:00 2001 From: radishzzz Date: Fri, 17 Jan 2025 02:50:53 +0000 Subject: [PATCH] refactor: update and theme configuration --- astro.config.ts | 12 +-- package.json | 8 +- pnpm-lock.yaml | 18 +--- src/components/Head.astro | 13 +-- src/config/index.ts | 35 +++--- src/content/config.ts | 8 +- src/plugins/rehype-component-admonition.mjs | 33 ++++++ src/plugins/rehype-component-admonition.ts | 43 -------- src/plugins/rehype-component-github-card.mjs | 105 ++++++++++++++++++ src/plugins/rehype-component-github-card.ts | 106 ------------------- src/plugins/remark-directive-rehype.js | 30 ++++++ src/plugins/remark-directive-rehype.ts | 41 ------- src/plugins/remark-excerpt.js | 16 +++ src/plugins/remark-excerpt.ts | 12 --- src/plugins/remark-reading-time.mjs | 15 +++ src/plugins/remark-reading-time.ts | 14 --- src/styles/font.css | 0 src/types/index.d.ts | 1 + src/utils/content.config.ts | 99 ++++++++++------- 19 files changed, 299 insertions(+), 310 deletions(-) create mode 100644 src/plugins/rehype-component-admonition.mjs delete mode 100644 src/plugins/rehype-component-admonition.ts create mode 100644 src/plugins/rehype-component-github-card.mjs delete mode 100644 src/plugins/rehype-component-github-card.ts create mode 100644 src/plugins/remark-directive-rehype.js delete mode 100644 src/plugins/remark-directive-rehype.ts create mode 100644 src/plugins/remark-excerpt.js delete mode 100644 src/plugins/remark-excerpt.ts create mode 100644 src/plugins/remark-reading-time.mjs delete mode 100644 src/plugins/remark-reading-time.ts create mode 100644 src/styles/font.css diff --git a/astro.config.ts b/astro.config.ts index 2622b3c..551fa7e 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -23,11 +23,11 @@ import remarkSectionize from 'remark-sectionize' // Markdown Extensions import UnoCSS from 'unocss/astro' import { themeConfig } from './src/config' -import { AdmonitionComponent } from './src/plugins/rehype-component-admonition.ts' -import { GithubCardComponent } from './src/plugins/rehype-component-github-card.ts' -import { parseDirectiveNode } from './src/plugins/remark-directive-rehype.ts' -import { remarkExcerpt } from './src/plugins/remark-excerpt.ts' -import { remarkReadingTime } from './src/plugins/remark-reading-time.ts' +import { AdmonitionComponent } from './src/plugins/rehype-component-admonition.mjs' +import { GithubCardComponent } from './src/plugins/rehype-component-github-card.mjs' +import { parseDirectiveNode } from './src/plugins/remark-directive-rehype.js' +import { remarkExcerpt } from './src/plugins/remark-excerpt.js' +import { remarkReadingTime } from './src/plugins/remark-reading-time.mjs' const { url }: { url: ThemeConfig['site']['url'] } = themeConfig.site @@ -69,9 +69,9 @@ export default defineConfig({ remarkMath, remarkReadingTime, remarkExcerpt, + remarkSectionize, remarkGithubAdmonitionsToDirectives, remarkDirective, - remarkSectionize, parseDirectiveNode, ], rehypePlugins: [ diff --git a/package.json b/package.json index 687d392..1dcbb19 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "astro": "^5.1.6", "astro-compress": "^2.3.6", "astro-robots-txt": "^1.0.0", + "hastscript": "^9.0.0", "markdown-it": "^14.1.0", "overlayscrollbars": "^2.10.1", "photoswipe": "^5.4.4", @@ -46,23 +47,18 @@ }, "devDependencies": { "@antfu/eslint-config": "^3.14.0", - "@types/hast": "^3.0.4", "@types/markdown-it": "^14.1.2", - "@types/mdast": "^4.0.4", "@types/node": "^22.10.6", "@types/sanitize-html": "^2.13.0", - "@types/unist": "^3.0.3", "@unocss/eslint-plugin": "^65.4.0", "astro-eslint-parser": "^1.1.0", "eslint": "^9.18.0", "eslint-plugin-astro": "^1.3.1", - "hastscript": "^9.0.0", "lint-staged": "^15.3.0", "mdast-util-to-string": "^4.0.0", "reading-time": "^1.5.0", "unocss": "^65.4.0", - "unocss-preset-theme": "^0.14.1", - "vfile": "^6.0.3" + "unocss-preset-theme": "^0.14.1" }, "lint-staged": { "*.{js,ts,jsx,tsx,astro}": "eslint --fix" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4fb925d..f8440fc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,6 +41,9 @@ importers: astro-robots-txt: specifier: ^1.0.0 version: 1.0.0 + hastscript: + specifier: ^9.0.0 + version: 9.0.0 markdown-it: specifier: ^14.1.0 version: 14.1.0 @@ -99,24 +102,15 @@ importers: '@antfu/eslint-config': specifier: ^3.14.0 version: 3.14.0(@typescript-eslint/utils@8.20.0(eslint@9.18.0(jiti@2.4.2))(typescript@5.7.3))(@unocss/eslint-plugin@65.4.0(eslint@9.18.0(jiti@2.4.2))(typescript@5.7.3))(@vue/compiler-sfc@3.5.13)(astro-eslint-parser@1.1.0(typescript@5.7.3))(eslint-plugin-astro@1.3.1(eslint@9.18.0(jiti@2.4.2))(typescript@5.7.3))(eslint@9.18.0(jiti@2.4.2))(typescript@5.7.3) - '@types/hast': - specifier: ^3.0.4 - version: 3.0.4 '@types/markdown-it': specifier: ^14.1.2 version: 14.1.2 - '@types/mdast': - specifier: ^4.0.4 - version: 4.0.4 '@types/node': specifier: ^22.10.6 version: 22.10.6 '@types/sanitize-html': specifier: ^2.13.0 version: 2.13.0 - '@types/unist': - specifier: ^3.0.3 - version: 3.0.3 '@unocss/eslint-plugin': specifier: ^65.4.0 version: 65.4.0(eslint@9.18.0(jiti@2.4.2))(typescript@5.7.3) @@ -129,9 +123,6 @@ importers: eslint-plugin-astro: specifier: ^1.3.1 version: 1.3.1(eslint@9.18.0(jiti@2.4.2))(typescript@5.7.3) - hastscript: - specifier: ^9.0.0 - version: 9.0.0 lint-staged: specifier: ^15.3.0 version: 15.3.0 @@ -147,9 +138,6 @@ importers: unocss-preset-theme: specifier: ^0.14.1 version: 0.14.1(@unocss/core@65.4.0) - vfile: - specifier: ^6.0.3 - version: 6.0.3 packages: diff --git a/src/components/Head.astro b/src/components/Head.astro index 681fc23..0388109 100644 --- a/src/components/Head.astro +++ b/src/components/Head.astro @@ -9,8 +9,8 @@ interface Props { const { postTitle, postDescription, postImage } = Astro.props const { title, subtitle, description, author, url, favicon } = themeConfig.site -const { language } = themeConfig.global const { light: { backgroundStart: lightMode }, dark: { backgroundStart: darkMode } } = themeConfig.color +const { language } = themeConfig.global const { verification = {}, twitterID = '', facebookID = '', facebookLink = '', googleAnalyticsID = '', umamiAnalyticsID = '', siteScreenshot = '' } = themeConfig.seo ?? {} const { google = '', bing = '', yandex = '', baidu = '' } = verification const { cdn, commentURL = '', imageHostURL = '', customGoogleAnalyticsURL = '', customUmamiAnalyticsURL = '', customUmamiAnalyticsJS = '' } = themeConfig.preload @@ -35,11 +35,12 @@ const { cdn, commentURL = '', imageHostURL = '', customGoogleAnalyticsURL = '', - + {commentURL && } {imageHostURL && } {customGoogleAnalyticsURL && } {customUmamiAnalyticsURL && } + @@ -89,15 +90,11 @@ const { cdn, commentURL = '', imageHostURL = '', customGoogleAnalyticsURL = '', <>