diff --git a/astro.config.ts b/astro.config.ts index 84547f1..5a76790 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -2,17 +2,14 @@ import mdx from '@astrojs/mdx' import partytown from '@astrojs/partytown' import sitemap from '@astrojs/sitemap' -import { transformerCopyButton } from '@rehype-pretty/transformers' import compress from 'astro-compress' import robotsTxt from 'astro-robots-txt' // Rehype plugins (HTML processors) import { defineConfig } from 'astro/config' import rehypeAutolinkHeadings from 'rehype-autolink-headings' -import rehypeComponents from 'rehype-components' import rehypeExternalLinks from 'rehype-external-links' import rehypeKatex from 'rehype-katex' -import rehypePrettyCode from 'rehype-pretty-code' import rehypeSlug from 'rehype-slug' // Remark plugins (Markdown processors) @@ -25,14 +22,9 @@ import remarkSectionize from 'remark-sectionize' import UnoCSS from 'unocss/astro' import { themeConfig } from './src/config' import { langMap } from './src/i18n/config' -import { AdmonitionComponent } from './src/plugins/rehype-component-admonition' -import { GithubCardComponent } from './src/plugins/rehype-component-github-card' -import { parseDirectiveNode } from './src/plugins/remark-directive-rehype' -import { remarkExcerpt } from './src/plugins/remark-excerpt' import { remarkReadingTime } from './src/plugins/remark-reading-time' const url = themeConfig.site.url -const { light, dark } = themeConfig.color const locale = themeConfig.global.locale const linkPrefetch = themeConfig.preload.linkPrefetch const imageDomain = new URL(themeConfig.preload.imageHostURL as string).hostname @@ -57,7 +49,9 @@ export default defineConfig({ defaultLocale: locale, }, integrations: [ - UnoCSS({ injectReset: true }), + UnoCSS({ + injectReset: true, + }), mdx(), partytown({ config: { @@ -65,49 +59,20 @@ export default defineConfig({ }, }), sitemap(), - robotsTxt({ - sitemap: true, - }), - compress({ - HTML: { - 'html-minifier-terser': { - removeAttributeQuotes: false, - removeScriptTypeAttributes: true, - removeStyleLinkTypeAttributes: true, - sortAttributes: true, - sortClassName: true, - }, - }, - }), + robotsTxt(), + compress(), ], markdown: { remarkPlugins: [ remarkMath, remarkDirective, remarkGithubAdmonitionsToDirectives, - parseDirectiveNode, remarkSectionize, remarkReadingTime, - remarkExcerpt, ], rehypePlugins: [ rehypeSlug, rehypeKatex, - [ - rehypePrettyCode, - { - theme: { - dark: dark.codeTheme, - light: light.codeTheme, - }, - transformers: [ - transformerCopyButton({ - visibility: 'hover', - feedbackDuration: 2_500, - }), - ], - }, - ], [ rehypeExternalLinks, { @@ -116,19 +81,6 @@ export default defineConfig({ protocols: ['http', 'https', 'mailto'], }, ], - [ - rehypeComponents, - { - components: { - github: GithubCardComponent, - note: (properties: { 'has-directive-label'?: boolean }, children: any[]) => AdmonitionComponent(properties, children, 'note'), - tip: (properties: { 'has-directive-label'?: boolean }, children: any[]) => AdmonitionComponent(properties, children, 'tip'), - important: (properties: { 'has-directive-label'?: boolean }, children: any[]) => AdmonitionComponent(properties, children, 'important'), - caution: (properties: { 'has-directive-label'?: boolean }, children: any[]) => AdmonitionComponent(properties, children, 'caution'), - warning: (properties: { 'has-directive-label'?: boolean }, children: any[]) => AdmonitionComponent(properties, children, 'warning'), - }, - }, - ], [ rehypeAutolinkHeadings, { diff --git a/package.json b/package.json index 7bfa374..3ead1d0 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "version": "0.0.1", "packageManager": "pnpm@10.6.4", "scripts": { - "dev": "astro dev", - "build": "astro build", + "dev": "astro check && astro dev", + "build": "astro check && astro build", "preview": "astro preview", "astro": "astro", "lint": "eslint .", @@ -15,40 +15,34 @@ "prepare": "git init && npx husky install" }, "dependencies": { - "@astrojs/check": "^0.9.4", "@astrojs/mdx": "^4.2.1", "@astrojs/partytown": "^2.1.4", "@astrojs/rss": "^4.0.11", "@astrojs/sitemap": "^3.3.0", - "@rehype-pretty/transformers": "^0.13.2", "astro": "^5.5.3", "astro-compress": "^2.3.6", "astro-og-canvas": "^0.7.0", "astro-robots-txt": "^1.0.0", "canvaskit-wasm": "^0.39.1", - "hastscript": "^9.0.1", "markdown-it": "^14.1.0", "overlayscrollbars": "^2.11.1", "photoswipe": "^5.4.4", "rehype-autolink-headings": "^7.1.0", - "rehype-components": "^0.3.0", "rehype-external-links": "^3.0.0", "rehype-katex": "^7.0.1", - "rehype-pretty-code": "^0.14.1", "rehype-slug": "^6.0.0", "remark-directive": "^4.0.0", "remark-github-admonitions-to-directives": "^2.1.0", "remark-math": "^6.0.0", "remark-sectionize": "^2.1.0", - "sanitize-html": "^2.14.0", + "sanitize-html": "^2.15.0", "sharp": "^0.33.5", - "typescript": "~5.8.2", - "unist-util-visit": "^5.0.0" + "typescript": "~5.8.2" }, "devDependencies": { "@antfu/eslint-config": "^4.10.1", + "@astrojs/check": "^0.9.4", "@types/markdown-it": "^14.1.2", - "@types/mdast": "^4.0.4", "@types/node": "^22.13.10", "@types/sanitize-html": "^2.13.0", "@unocss/eslint-plugin": "66.1.0-beta.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a63a995..5a00d3a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -84,8 +84,8 @@ importers: specifier: ^2.1.0 version: 2.1.0 sanitize-html: - specifier: ^2.14.0 - version: 2.14.0 + specifier: ^2.15.0 + version: 2.15.0 sharp: specifier: ^0.33.5 version: 0.33.5 @@ -3154,8 +3154,8 @@ packages: run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} - sanitize-html@2.14.0: - resolution: {integrity: sha512-CafX+IUPxZshXqqRaG9ZClSlfPVjSxI0td7n07hk8QO2oO+9JDnlcL8iM8TWeOXOIBFgIOx6zioTzM53AOMn3g==} + sanitize-html@2.15.0: + resolution: {integrity: sha512-wIjst57vJGpLyBP8ioUbg6ThwJie5SuSIjHxJg53v5Fg+kUK+AXlb7bK3RNXpp315MvwM+0OBGCV6h5pPHsVhA==} sax@1.4.1: resolution: {integrity: sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==} @@ -7693,7 +7693,7 @@ snapshots: dependencies: queue-microtask: 1.2.3 - sanitize-html@2.14.0: + sanitize-html@2.15.0: dependencies: deepmerge: 4.3.1 escape-string-regexp: 4.0.0 diff --git a/src/layouts/Head.astro b/src/layouts/Head.astro index df7a313..9e6091f 100644 --- a/src/layouts/Head.astro +++ b/src/layouts/Head.astro @@ -57,6 +57,7 @@ const pageImage = postSlug {imageHostURL && } {imageHostURL && } +