diff --git a/astro.config.mjs b/astro.config.mjs index ac541a0..bb7455e 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,4 +1,5 @@ import { defineConfig } from "astro/config"; +import { CODE_THEME } from "./src/consts.ts"; import mdx from "@astrojs/mdx"; import icon from "astro-icon"; import terser from "@rollup/plugin-terser"; @@ -43,12 +44,12 @@ export default defineConfig({ }), terser({ compress: true, mangle: true, - }), sitemap(), tailwind(), pagefind(), astroI18next(), playformCompress(), partytown()], + }), sitemap(), tailwind(), pagefind(), astroI18next(), playformCompress()], markdown: { shikiConfig: { themes: { - light: "github-light", - dark: "github-dark", + light: CODE_THEME.light, + dark: CODE_THEME.dark, }, transformers: [ { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 865ccdb..e90f320 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -527,4 +527,26 @@ ### Fix - 修复了滚动问题 -- 修复了在站内跳转时目录中 `active` 保留的问题 \ No newline at end of file +- 修复了在站内跳转时目录中 `active` 保留的问题 + +## [2.8.0] - 2024-11-3 + +### Features + +- 学习了 Astro 中自定义元素的用法,现在两个交互按钮单独分为 widget 可以重用 +- 在 `consts.ts` 新增了 `SITE_LANG` 作为网站的语言配置 +- 在 `consts.ts` 新增了 `DAIYSUI_THEME` 作为 DaiysUI 的主题配置,详见 https://daisyui.com/docs/themes/ (此内容需要更多适配) +- 在 `consts.ts` 新增了 `CODE_THEME` 作为 shiki 的主题配置 + +#### preview + +### Refactored + +- 侧边栏与导航栏修改 +- 移除了不必要的工具 +- 修改了 active 样式(选择性) + +### Fix + +- 修复了控制台报错 +- 补上了 `ProjectCard` 缺失的颜色过渡 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5b9c29d..ba39a51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "frosti", - "version": "2.7.0", + "version": "2.8.0-rc", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "frosti", - "version": "2.7.0", + "version": "2.8.0-rc", "dependencies": { "@astrojs/check": "^0.9.3", "@astrojs/mdx": "^3.1.7", @@ -17190,4 +17190,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 7c83d72..fb70ca7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "frosti", "type": "module", - "version": "2.7.0", + "version": "2.8.0-rc", "scripts": { "dev": "astro dev", "start": "astro dev", @@ -69,4 +69,4 @@ "@iconify/tools": "^4.0.5" } } -} +} \ No newline at end of file diff --git a/src/components/BaseCard.astro b/src/components/BaseCard.astro index 32a5511..2e2600d 100644 --- a/src/components/BaseCard.astro +++ b/src/components/BaseCard.astro @@ -25,7 +25,6 @@ const hasTags = tags && tags.length > 0;
{ image && ( diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 8e3fac7..acb0e79 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -4,7 +4,7 @@ import { USER_SITE } from "../consts"; ---
@@ -49,7 +69,7 @@ const { title, image, includeSidebar = true } = Astro.props; - + ) } @@ -131,7 +151,7 @@ const { title, image, includeSidebar = true } = Astro.props; }); document.addEventListener("DOMContentLoaded", () => { - const astroPageLoadEvent = new Event("swup:page:view"); - document.dispatchEvent(astroPageLoadEvent); + const ContentLoadEvent = new Event("swup:page:view"); + document.dispatchEvent(ContentLoadEvent); }); diff --git a/src/styles/global.scss b/src/styles/global.scss index 1846238..9495126 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -59,7 +59,16 @@ a { @apply my-2; } -html[data-theme="dracula"] { +html[data-theme-type="light"] { + #content-box { + .active { + color: oklch(var(--n)); + background-color: oklch(var(--b3)); + } + } +} + +html[data-theme-type="dark"] { --pagefind-ui-primary: oklch(var(--nc)); --pagefind-ui-text: oklch(var(--nc)); --pagefind-ui-background: oklch(var(--b1)); diff --git a/src/utils/table-of-content.mjs b/src/utils/table-of-content.mjs deleted file mode 100644 index b75bcd7..0000000 --- a/src/utils/table-of-content.mjs +++ /dev/null @@ -1,87 +0,0 @@ -import { codeToHtml } from "shiki"; - -export async function highlightCode(block) { - const code = block.rich_text.map((text) => text.plain_text).join("\n"); // 输入代码片段 - - const html = await codeToHtml(code, { - lang: block.language, - theme: "vitesse-dark", - transformers: [ - { - preprocess(code, { lang }) { - this.lang = lang; - return code; - }, - root(node) { - if (node.tagName === "pre") { - node.tagName = "figure"; - node.properties.className = ["highlight", this.lang]; - } - }, - pre(node) { - const toolsDiv = { - type: "element", - tagName: "div", - properties: { className: ["highlight-tools"] }, - children: [ - { - type: "element", - tagName: "div", - properties: { className: ["code-lang"] }, - children: [{ type: "text", value: this.lang.toUpperCase() }], - }, - ], - }; - const lineNumberCode = { - type: "element", - tagName: "code", - children: [], - }; - const lineNumberPre = { - type: "element", - tagName: "pre", - properties: { className: ["astro-code", "gutter"] }, - children: [lineNumberCode], - }; - const codeContentPre = { - type: "element", - tagName: "pre", - properties: { className: ["astro-code", "code"] }, - children: [], - }; - node.children.forEach((lineNode, index, count) => { - count = 0; - lineNode.children.forEach(() => { - if (count & (1 === 1)) { - lineNumberCode.children.push({ - type: "element", - tagName: "div", - properties: { className: ["line"] }, - children: [{ type: "text", value: String(index + 1) }], - }); - index++; - } - count++; - }); - - codeContentPre.children.push(lineNode); - }); - const table = { - type: "element", - tagName: "div", - properties: { className: ["highlight-code"] }, - children: [lineNumberPre, codeContentPre], - }; - return { - type: "element", - tagName: "figure", - properties: { className: ["highlight", this.lang] }, - children: [toolsDiv, table], - }; - }, - }, - ], - }); - - return html; -} diff --git a/src/widget/BackToTopButton.astro b/src/widget/BackToTopButton.astro new file mode 100644 index 0000000..3217284 --- /dev/null +++ b/src/widget/BackToTopButton.astro @@ -0,0 +1,40 @@ +--- +const { id, className } = Astro.props; +--- + + + + diff --git a/src/widget/ThemeButton.astro b/src/widget/ThemeButton.astro new file mode 100644 index 0000000..f59a77b --- /dev/null +++ b/src/widget/ThemeButton.astro @@ -0,0 +1,101 @@ +--- +import { DAISYUI_THEME } from "../consts"; +const { id, className } = Astro.props; +--- + + + + + +