[
  {
    "path": ".gitattributes",
    "content": "* text=auto eol=lf"
  },
  {
    "path": ".github/workflows/close-inactive-issues.yml",
    "content": "name: Close inactive issues\n\non:\n  schedule:\n    - cron: '30 1 * * *'\n\njobs:\n  close-issues:\n    if: github.repository == 'lxchapu/astro-gyoza'\n    runs-on: ubuntu-latest\n    permissions:\n      issues: write\n      pull-requests: write\n    steps:\n      - uses: actions/stale@v9\n        with:\n          days-before-stale: 14\n          days-before-close: 7\n          days-before-pr-close: -1\n          stale-issue-label: 'stale'\n          stale-issue-message: 'This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.'\n          stale-pr-message: 'This PR is stale because it has been open 14 days with no activity.'\n          close-issue-message: 'This issue was closed because it has been inactive for 7 days since being marked as stale.'\n"
  },
  {
    "path": ".gitignore",
    "content": "# build output\ndist/\n\n# generated types\n.astro/\n\n# dependencies\nnode_modules/\n\n# logs\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\npnpm-debug.log*\n\n# environment variables\n.env\n.env.production\n\n# macOS-specific files\n.DS_Store\n\n# jetbrains setting folder\n.idea/\n"
  },
  {
    "path": ".prettierignore",
    "content": ".astro/\nnode_modules/\ndist/\npnpm-lock.yaml"
  },
  {
    "path": ".prettierrc",
    "content": "{\n  \"printWidth\": 100,\n  \"semi\": false,\n  \"singleQuote\": true,\n  \"plugins\": [\"prettier-plugin-astro\"],\n  \"overrides\": [\n    {\n      \"files\": \"*.astro\",\n      \"options\": {\n        \"parser\": \"astro\"\n      }\n    }\n  ]\n}\n"
  },
  {
    "path": ".vscode/extensions.json",
    "content": "{\n  \"recommendations\": [\"astro-build.astro-vscode\"],\n  \"unwantedRecommendations\": []\n}\n"
  },
  {
    "path": ".vscode/launch.json",
    "content": "{\n  \"version\": \"0.2.0\",\n  \"configurations\": [\n    {\n      \"command\": \"./node_modules/.bin/astro dev\",\n      \"name\": \"Development server\",\n      \"request\": \"launch\",\n      \"type\": \"node-terminal\"\n    }\n  ]\n}\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2024 柃夏chapu\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Gyoza\n\nGyoza is a static blog template built with Astro and React.\n\n![astro version](https://img.shields.io/badge/astro-4.6-red)\n![node version](https://img.shields.io/badge/node-18.18-green)\n\nDemo Site:\n\n- [gyoza.lxchapu.com](https://gyoza.lxchapu.com)\n- [www.lxchapu.com](https://www.lxchapu.com)\n\nEnjoy it!\n\n## 📷 Screenshots\n\n![Preview](https://s2.loli.net/2024/05/06/A9rzC3Uym7RwdQc.webp)\n\n## 🎉 Features\n\n- ✅ 有着规范的 URL 和 OpenGraph 信息，对 SEO 友好\n- ✅ 支持站点地图\n- ✅ 支持 RSS 订阅\n- ✅ 支持夜间模式\n- ✅ 特殊日期变灰\n- ✅ 简单干净的配色和主题\n- ✅ 支持评论系统\n- ✅ 支持代码高亮\n\n## 🔧 Tech Stack\n\n- [Astro](https://astro.build/)\n- [React](https://reactjs.org/)\n- [Tailwind CSS](https://tailwindcss.com/)\n- [Framer Motion](https://www.framer.com/motion/)\n- [Jotai](https://jotai.org/)\n\n## 📖 Documentation\n\n前往：[Documentation](https://gyoza.lxchapu.com/posts/guide)\n\n## 🚀 Project Structure\n\n```text\n├── public/\n├── src/\n│   ├── components/\n│   ├── content/\n│   ├── layouts/\n│   ├── pages/\n│   ├── plugins/\n│   ├── store/\n│   ├── styles/\n│   ├── utils/\n│   └── config.json\n├── astro.config.mjs\n├── README.md\n├── package.json\n└── tsconfig.json\n```\n\n网站配置保存在 `config.json` 文件。\n\n## 🧞 Commands\n\n| Command        | Action                                       |\n| :------------- | :------------------------------------------- |\n| `pnpm i`       | Installs dependencies                        |\n| `pnpm dev`     | Starts local dev server at `localhost:4321`  |\n| `pnpm build`   | Build your production site to `./dist/`      |\n| `pnpm preview` | Preview your build locally, before deploying |\n| `pnpm format`  | Format code using Prettier                   |\n"
  },
  {
    "path": "astro.config.js",
    "content": "import { defineConfig } from 'astro/config'\nimport { remarkReadingTime } from './src/plugins/remarkReadingTime'\nimport { rehypeCodeBlock } from './src/plugins/rehypeCodeBlock'\nimport { rehypeTableBlock } from './src/plugins/rehypeTableBlock'\nimport { rehypeCodeHighlight } from './src/plugins/rehypeCodeHighlight'\nimport { rehypeImage } from './src/plugins/rehypeImage'\nimport { rehypeLink } from './src/plugins/rehypeLink'\nimport { rehypeHeading } from './src/plugins/rehypeHeading'\nimport remarkDirective from 'remark-directive'\nimport { remarkSpoiler } from './src/plugins/remarkSpoiler'\nimport { remarkEmbed } from './src/plugins/remarkEmbed'\nimport tailwind from '@astrojs/tailwind'\nimport react from '@astrojs/react'\nimport sitemap from '@astrojs/sitemap'\nimport { rehypeHeadingIds } from '@astrojs/markdown-remark'\nimport { site } from './src/config.json'\nimport remarkMath from 'remark-math'\nimport rehypeKatex from 'rehype-katex'\nimport swup from '@swup/astro'\n\n// https://astro.build/config\nexport default defineConfig({\n  site: site.url,\n  integrations: [\n    tailwind(),\n    react(),\n    sitemap(),\n    swup({\n      theme: false,\n      animationClass: 'swup-transition-',\n      containers: ['main'],\n      morph: ['[component-export=\"Provider\"]'],\n    }),\n  ],\n  markdown: {\n    syntaxHighlight: false,\n    smartypants: false,\n    remarkPlugins: [remarkMath, remarkDirective, remarkEmbed, remarkSpoiler, remarkReadingTime],\n    rehypePlugins: [\n      rehypeHeadingIds,\n      rehypeKatex,\n      rehypeLink,\n      rehypeImage,\n      rehypeHeading,\n      rehypeCodeBlock,\n      rehypeCodeHighlight,\n      rehypeTableBlock,\n    ],\n    remarkRehype: { footnoteLabel: '参考', footnoteBackLabel: '返回正文' },\n  },\n  vite: {\n    build: {\n      rollupOptions: {\n        external: ['/pagefind/pagefind.js'],\n      },\n    },\n  },\n})\n"
  },
  {
    "path": "commitlint.config.js",
    "content": "export default {\n  extends: ['@commitlint/config-conventional'],\n}\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"astro-gyoza\",\n  \"type\": \"module\",\n  \"version\": \"0.0.1\",\n  \"scripts\": {\n    \"prepare\": \"pnpm exec simple-git-hooks\",\n    \"dev\": \"astro dev\",\n    \"build\": \"astro check && astro build && pagefind --site dist\",\n    \"preview\": \"astro preview\",\n    \"astro\": \"astro\",\n    \"lint\": \"prettier --write .\",\n    \"new-friend\": \"node scripts/new-friend.js\",\n    \"new-post\": \"node scripts/new-post.js\",\n    \"new-project\": \"node scripts/new-project.js\"\n  },\n  \"dependencies\": {\n    \"@astrojs/check\": \"^0.5.10\",\n    \"@astrojs/markdown-remark\": \"^5.1.0\",\n    \"@astrojs/react\": \"^3.3.0\",\n    \"@astrojs/rss\": \"^4.0.5\",\n    \"@astrojs/sitemap\": \"^3.1.3\",\n    \"@astrojs/tailwind\": \"^5.1.0\",\n    \"@radix-ui/react-dialog\": \"^1.0.5\",\n    \"@shikijs/rehype\": \"^1.3.0\",\n    \"@swup/astro\": \"^1.4.1\",\n    \"@types/chroma-js\": \"^2.4.4\",\n    \"@types/lodash-es\": \"^4.17.12\",\n    \"@types/react\": \"^18.2.78\",\n    \"@types/react-dom\": \"^18.2.25\",\n    \"@waline/client\": \"^3.1.3\",\n    \"astro\": \"^4.6.1\",\n    \"chroma-js\": \"^2.4.2\",\n    \"clsx\": \"^2.1.0\",\n    \"framer-motion\": \"^11.1.5\",\n    \"hastscript\": \"^9.0.0\",\n    \"jotai\": \"^2.8.0\",\n    \"katex\": \"^0.16.10\",\n    \"lodash-es\": \"^4.17.21\",\n    \"mdast-util-to-string\": \"^4.0.0\",\n    \"pagefind\": \"^1.1.0\",\n    \"qrcode.react\": \"^3.1.0\",\n    \"react\": \"^18.2.0\",\n    \"react-dom\": \"^18.2.0\",\n    \"react-toastify\": \"^10.0.5\",\n    \"reading-time\": \"^1.5.0\",\n    \"rehype-katex\": \"^7.0.0\",\n    \"remark-directive\": \"^3.0.0\",\n    \"remark-math\": \"^6.0.0\",\n    \"tailwindcss\": \"^3.4.3\",\n    \"typescript\": \"^5.4.5\",\n    \"unist-util-visit\": \"^5.0.0\"\n  },\n  \"devDependencies\": {\n    \"@commitlint/cli\": \"^19.3.0\",\n    \"@commitlint/config-conventional\": \"^19.2.2\",\n    \"@inquirer/prompts\": \"^5.0.2\",\n    \"lint-staged\": \"^15.2.2\",\n    \"micromark-util-symbol\": \"^2.0.0\",\n    \"prettier\": \"^3.2.5\",\n    \"prettier-plugin-astro\": \"^0.13.0\",\n    \"simple-git-hooks\": \"^2.11.1\"\n  },\n  \"simple-git-hooks\": {\n    \"commit-msg\": \"pnpm exec commitlint --edit $1\",\n    \"pre-commit\": \"pnpm exec lint-staged\"\n  },\n  \"lint-staged\": {\n    \"*.{js,jsx,ts,tsx.astro,md,css,json}\": \"prettier --write\"\n  }\n}\n"
  },
  {
    "path": "scripts/new-friend.js",
    "content": "import { input } from '@inquirer/prompts'\nimport fs from 'fs'\nimport path from 'path'\nimport { isFileNameSafe } from './utils.js'\n\nfunction getFriendFullPath(fileName) {\n  return path.join('./src/content/friends', `${fileName}.yaml`)\n}\n\nconst fileName = await input({\n  message: '请输入文件名称',\n  validate: (value) => {\n    if (!isFileNameSafe(value)) {\n      return '文件名只能包含字母、数字和连字符'\n    }\n    const fullPath = getFriendFullPath(value)\n    if (fs.existsSync(fullPath)) {\n      return `${fullPath} 已存在`\n    }\n    return true\n  },\n})\n\nconst title = await input({\n  message: '请输入标题',\n})\nconst description = await input({\n  message: '请输入描述',\n})\nconst link = await input({\n  message: '请输入地址',\n})\nconst avatar = await input({\n  message: '请输入头像地址',\n})\n\nconst content = `title: ${title}\ndescription: ${description}\nlink: ${link}\navatar: ${avatar}\n`\n\nconst fullPath = getFriendFullPath(fileName)\nfs.writeFileSync(fullPath, content)\nconsole.log(`${fullPath} 创建成功`)\n"
  },
  {
    "path": "scripts/new-post.js",
    "content": "import { input } from '@inquirer/prompts'\nimport fs from 'fs'\nimport path from 'path'\nimport { isFileNameSafe } from './utils.js'\n\nfunction getPostFullPath(fileName) {\n  return path.join('./src/content/posts', `${fileName}.md`)\n}\n\nconst fileName = await input({\n  message: '请输入文件名称',\n  validate: (value) => {\n    if (!isFileNameSafe(value)) {\n      return '文件名只能包含字母、数字和连字符'\n    }\n    const fullPath = getPostFullPath(value)\n    if (fs.existsSync(fullPath)) {\n      return `${fullPath} 已存在`\n    }\n    return true\n  },\n})\n\nconst title = await input({\n  message: '请输入文章标题',\n})\n\nconst content = `---\ntitle: ${title}\ndate: ${new Date().toISOString()}\ntags: []\ncomments: true\ndraft: false\n---\n`\n\nconst fullPath = getPostFullPath(fileName)\nfs.writeFileSync(fullPath, content)\nconsole.log(`${fullPath} 创建成功`)\n"
  },
  {
    "path": "scripts/new-project.js",
    "content": "import { input } from '@inquirer/prompts'\nimport fs from 'fs'\nimport path from 'path'\nimport { isFileNameSafe } from './utils.js'\n\nfunction getProjectFullPath(fileName) {\n  return path.join('./src/content/projects', `${fileName}.yaml`)\n}\n\nconst fileName = await input({\n  message: '请输入文件名称',\n  validate: (value) => {\n    if (!isFileNameSafe(value)) {\n      return '文件名只能包含字母、数字和连字符'\n    }\n    const fullPath = getProjectFullPath(value)\n    if (fs.existsSync(fullPath)) {\n      return `${fullPath} 已存在`\n    }\n    return true\n  },\n})\n\nconst title = await input({\n  message: '请输入项目名称',\n})\nconst description = await input({\n  message: '请输入项目描述',\n})\nconst link = await input({\n  message: '请输入项目地址',\n})\nconst image = await input({\n  message: '请输入预览图片地址',\n})\n\nconst content = `title: ${title}\ndescription: ${description}\nlink: ${link}\nimage: ${image}\n`\n\nconst fullPath = getProjectFullPath(fileName)\nfs.writeFileSync(fullPath, content)\nconsole.log(`${fullPath} 创建成功`)\n"
  },
  {
    "path": "scripts/utils.js",
    "content": "export function isFileNameSafe(fileName) {\n  return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(fileName)\n}\n"
  },
  {
    "path": "src/components/AnimatedSignature.tsx",
    "content": "import Svg from '@/assets/signature.svg?raw'\n\nexport function AnimatedSignature() {\n  return (\n    <div\n      className=\"animated-signature\"\n      dangerouslySetInnerHTML={{\n        __html: Svg,\n      }}\n    ></div>\n  )\n}\n"
  },
  {
    "path": "src/components/BackToTopFAB.tsx",
    "content": "import { useAtomValue } from 'jotai'\nimport { pageScrollLocationAtom } from '@/store/scrollInfo'\nimport { AnimatePresence, motion } from 'framer-motion'\n\nexport function BackToTopFAB() {\n  const scrollY = useAtomValue(pageScrollLocationAtom)\n  const isShow = scrollY > 100\n\n  return (\n    <div className=\"fixed right-4 bottom-6 z-10\">\n      <AnimatePresence>{isShow && <BackToTop />}</AnimatePresence>\n    </div>\n  )\n}\n\nfunction BackToTop() {\n  const handleBackToTop = () => {\n    window.scrollTo({\n      top: 0,\n      behavior: 'smooth',\n    })\n  }\n\n  return (\n    <motion.button\n      className=\"size-10 rounded-full shadow-lg shadow-zinc-800/5 border border-primary bg-white/50 dark:bg-zinc-800/50 backdrop-blur\"\n      type=\"button\"\n      aria-label=\"Back to top\"\n      onClick={handleBackToTop}\n      initial={{ opacity: 0, scale: 0 }}\n      animate={{ opacity: 1, scale: 1 }}\n      exit={{ opacity: 0, scale: 0 }}\n    >\n      <i className=\"iconfont icon-rocket\"></i>\n    </motion.button>\n  )\n}\n"
  },
  {
    "path": "src/components/CategoryList.astro",
    "content": "---\ninterface Props {\n  categories: {\n    name: string\n    slug: string\n    count: number\n  }[]\n}\n\nconst { categories } = Astro.props\n---\n\n{\n  categories.length === 0 ? (\n    <div class=\"text-center text-sm\">作者懒得分类🤪</div>\n  ) : (\n    <div class=\"space-y-2.5\">\n      {categories.map((category) => (\n        <a class=\"relative block group\" href={`/categories/${category.slug}`}>\n          <div class=\"absolute -z-1 inset-0 rounded-lg bg-accent/10 group-hover:transition group-hover:bg-accent/20 group-hover:scale-105\" />\n          <div class=\"px-2.5 py-2 text-sm flex gap-1 select-none\">\n            <i class=\"shrink-0 iconfont icon-folder\" />\n            <span class=\"grow\">{category.name}</span>\n            <span class=\"shrink-0\">{category.count}</span>\n          </div>\n        </a>\n      ))}\n    </div>\n  )\n}\n"
  },
  {
    "path": "src/components/Flashlight.tsx",
    "content": "import { useLayoutEffect, useState } from 'react'\n\nexport function Flashlight() {\n  const [cursorX, setCursorX] = useState(0)\n  const [cursorY, setCursorY] = useState(0)\n  const isMobile = !window.matchMedia('(hover: hover)').matches\n\n  if (isMobile) {\n    return null\n  }\n\n  const backgroundImage = `radial-gradient(\n    circle 16vmax at ${cursorX}px ${cursorY}px,\n    rgba(0, 0, 0, 0) 0%,\n    rgba(0, 0, 0, 0.5) 80%,\n    rgba(0, 0, 0, 0.8) 100%\n  )`\n\n  useLayoutEffect(() => {\n    const handleMouseMove = (event: MouseEvent) => {\n      setCursorX(event.clientX)\n      setCursorY(event.clientY)\n    }\n\n    document.addEventListener('mousemove', handleMouseMove)\n\n    return () => {\n      document.removeEventListener('mousemove', handleMouseMove)\n    }\n  }, [])\n\n  return (\n    <div\n      className=\"fixed inset-0 z-50 pointer-events-none\"\n      style={{\n        backgroundImage,\n        display: isMobile ? 'none' : 'block',\n      }}\n    ></div>\n  )\n}\n"
  },
  {
    "path": "src/components/FriendList.astro",
    "content": "---\nimport { getCollection } from 'astro:content'\n\nconst friends = await getCollection('friends')\n---\n\n<ul class=\"grid grid-cols-1 sm:grid-cols-2 gap-4 md:gap-8\">\n  {\n    friends.map((friend) => (\n      <li>\n        <a href={friend.data.link} target=\"_blank\" rel=\"noopener noreferrer external\">\n          <div class=\"p-4 flex gap-2 bg-accent/10 rounded-lg group\">\n            <img\n              class=\"shrink-0 size-16 object-contain rounded-full\"\n              src={friend.data.avatar}\n              alt={`Friend avatar: ${friend.data.title}`}\n              loading=\"lazy\"\n            />\n            <div class=\"min-w-0 grow\">\n              <div class=\"truncate font-bold text-xl group-hover:text-accent\">\n                {friend.data.title}\n              </div>\n              <div class=\"text-sm line-clamp-2\">{friend.data.description}</div>\n            </div>\n            <i class=\"shrink-0 iconfont icon-external-link group-hover:text-accent\" />\n          </div>\n        </a>\n      </li>\n    ))\n  }\n</ul>\n"
  },
  {
    "path": "src/components/Highlight.astro",
    "content": "---\ninterface Props {\n  class?: string\n}\n\nconst { class: className } = Astro.props\n---\n\n<span class=\"relative\" class:list={[className]}\n  ><span class=\"absolute -z-1 top-[30%] left-0 w-full h-[40%] bg-accent/30 -rotate-3\"></span><slot\n  /></span\n>\n"
  },
  {
    "path": "src/components/MarkdownWrapper.astro",
    "content": "---\ninterface Props {\n  class?: string\n}\n\nconst { class: className } = Astro.props\n---\n\n<article id=\"markdown-wrapper\" class=\"markdown\" class:list={[className]}>\n  <slot />\n</article>\n"
  },
  {
    "path": "src/components/ProjectList.astro",
    "content": "---\nimport { getCollection } from 'astro:content'\n\nconst projects = await getCollection('projects')\n---\n\n<ul class=\"grid grid-cols-1 sm:grid-cols-2 gap-4 md:gap-8\">\n  {\n    projects.map((project) => (\n      <li>\n        <a href={project.data.link} target=\"_blank\" rel=\"noopener noreferrer external\">\n          <div class=\"rounded-lg bg-accent/10 overflow-hidden group\">\n            <div class=\"aspect-video overflow-hidden\">\n              <img\n                class=\"size-full object-cover transition-transform group-hover:scale-110\"\n                src={project.data.image}\n                alt={`Project cover: ${project.data.title}`}\n                loading=\"lazy\"\n              />\n            </div>\n            <div class=\"p-4\">\n              <div class=\"group-hover:text-accent\">\n                <span class=\"text-xl font-bold\">{project.data.title}</span>\n                <i class=\"ml-2 iconfont icon-external-link\" />\n              </div>\n              <p class=\"mt-2 text-sm line-clamp-2\">{project.data.description}</p>\n            </div>\n          </div>\n        </a>\n      </li>\n    ))\n  }\n</ul>\n"
  },
  {
    "path": "src/components/RootPortal.tsx",
    "content": "import { createPortal } from 'react-dom'\n\nexport function RootPortal({\n  to = document.body,\n  children,\n}: {\n  to?: HTMLElement\n  children: React.ReactNode\n}) {\n  return createPortal(children, to)\n}\n"
  },
  {
    "path": "src/components/SectionBlock.astro",
    "content": "---\ninterface Props {\n  title: string\n}\n\nconst { title } = Astro.props\n---\n\n<section>\n  <div class=\"mb-8 font-bold uppercase tracking-widest text-accent\">{title}</div>\n  <slot />\n</section>\n"
  },
  {
    "path": "src/components/TagList.astro",
    "content": "---\ninterface Props {\n  tags: {\n    name: string\n    slug: string\n    count?: number\n  }[]\n}\n\nconst { tags } = Astro.props\n---\n\n{\n  tags.length === 0 ? (\n    <div class=\"text-center text-sm\">作者没有准备标签😦</div>\n  ) : (\n    <div class=\"flex flex-wrap gap-2.5\">\n      {tags.map((tag) => (\n        <a class=\"relative block group\" href={`/tags/${tag.slug}`}>\n          <div class=\"absolute -z-1 inset-0 rounded-lg bg-accent/10 group-hover:transition group-hover:bg-accent/20 group-hover:scale-105\" />\n          <div class=\"px-2.5 py-2 text-sm flex items-baseline gap-1 select-none\">\n            <span>{tag.name}</span>\n            {tag.count && <span class=\"text-xs\">({tag.count})</span>}\n          </div>\n        </a>\n      ))}\n    </div>\n  )\n}\n"
  },
  {
    "path": "src/components/Timeline.astro",
    "content": "---\nimport type { CollectionEntry } from 'astro:content'\nimport { getShortDate } from '@/utils/date'\n\ninterface Props {\n  posts: CollectionEntry<'posts'>[]\n}\n\nconst { posts } = Astro.props\n\nconst groupedPosts = posts.reduce<\n  {\n    year: number\n    posts: CollectionEntry<'posts'>[]\n  }[]\n>((acc, cur) => {\n  const year = cur.data.date.getFullYear()\n  const lastYearGroup = acc[acc.length - 1]\n  if (lastYearGroup && lastYearGroup.year === year) {\n    lastYearGroup.posts.push(cur)\n  } else {\n    acc.push({\n      year,\n      posts: [cur],\n    })\n  }\n  return acc\n}, [])\n---\n\n<section>\n  {\n    groupedPosts.map((year) => (\n      <div class=\"relative py-10\">\n        <h3\n          class=\"absolute -top-3 -left-8 text-[7rem] text-transparent leading-none font-bold pointer-events-none select-none font-['Atkinson']\"\n          style=\"-webkit-text-stroke: 2px rgb(var(--color-text-primary) / 0.1);\"\n        >\n          {year.year}\n        </h3>\n        <ul class=\"space-y-4\">\n          {year.posts.map((post) => (\n            <li class=\"flex items-baseline space-x-2\">\n              <span class=\"shrink-0 text-gray-600 dark:text-gray-300 text-sm\">\n                {getShortDate(post.data.date)}\n              </span>\n              <a\n                class=\"hover:text-accent/80 hover:underline underline-offset-2\"\n                href={`/posts/${post.slug}`}\n              >\n                {post.data.title}\n              </a>\n              {post.data.sticky > 0 && <i class=\"iconfont icon-pushpin text-red-500\" />}\n            </li>\n          ))}\n        </ul>\n      </div>\n    ))\n  }\n</section>\n"
  },
  {
    "path": "src/components/TimelineProgress.tsx",
    "content": "import { useEffect, useRef, useState } from 'react'\nimport { animate } from 'framer-motion'\nimport { getDaysInYear, getDiffInDays, getStartOfDay, getStartOfYear } from '@/utils/date'\n\nexport function TimelineProgress() {\n  const [currentYear, setCurrentYear] = useState(0)\n  const [dayOfYear, setDayOfYear] = useState(0)\n  const [percentOfYear, setPercentOfYear] = useState(0)\n  const [percentOfToday, setPercentOfToday] = useState(0)\n\n  const updateInfo = () => {\n    const now = new Date()\n    setCurrentYear(now.getFullYear())\n\n    const pastDays = getDiffInDays(getStartOfYear(now), now)\n    setDayOfYear(pastDays)\n    setPercentOfYear((pastDays / getDaysInYear(now)) * 100)\n\n    const pastTime = now.getTime() - getStartOfDay(now).getTime()\n    setPercentOfToday((pastTime / 86400 / 1000) * 100)\n  }\n\n  useEffect(() => {\n    updateInfo()\n    const interval = setInterval(updateInfo, 1000)\n    return () => {\n      clearInterval(interval)\n    }\n  }, [])\n\n  return (\n    <>\n      <p className=\"mt-4\">\n        今天是 {currentYear} 年的第 <CountUp to={dayOfYear} decimals={0} /> 天\n      </p>\n      <p className=\"mt-4\">\n        今年已过 <CountUp to={percentOfYear} decimals={5} />%\n      </p>\n      <p className=\"mt-4\">\n        今天已过 <CountUp to={percentOfToday} decimals={5} />%\n      </p>\n    </>\n  )\n}\n\nfunction CountUp({\n  to,\n  decimals,\n  duration = 1,\n}: {\n  to: number\n  decimals: number\n  duration?: number\n}) {\n  const node = useRef<HTMLSpanElement>(null)\n  const prev = useRef(0)\n\n  useEffect(() => {\n    if (!node.current) return\n\n    const control = animate(prev.current, to, {\n      duration,\n      onUpdate: (value) => {\n        node.current!.textContent = value.toFixed(decimals)\n      },\n    })\n    prev.current = to\n\n    return () => {\n      control.stop()\n    }\n  }, [to, decimals, duration])\n\n  return <span ref={node}></span>\n}\n"
  },
  {
    "path": "src/components/ToastContainer.tsx",
    "content": "import { ToastContainer as ReactToastContainer } from 'react-toastify'\nimport 'react-toastify/dist/ReactToastify.css';\n\nexport function ToastContainer() {\n  return <ReactToastContainer position='bottom-right' autoClose={3000} hideProgressBar closeButton={CloseButton}\n    toastClassName=\"!bg-primary !text-primary text-sm border border-primary\"\n  />\n}\n\nfunction CloseButton({ closeToast }: { closeToast: (event: React.MouseEvent<HTMLElement>) => void }) {\n  return <button type=\"button\" aria-label='Close Toast' className='text-lg opacity-50 hover:opacity-100' onClick={closeToast}>\n    <i className='iconfont icon-close'></i>\n  </button>\n}"
  },
  {
    "path": "src/components/comment/Comments.astro",
    "content": "---\nimport { Waline } from './Waline'\nimport { waline } from '@/config.json'\n---\n\n<div>\n  {waline.serverURL && <Waline {...waline} client:visible />}\n</div>\n"
  },
  {
    "path": "src/components/comment/Waline.tsx",
    "content": "import { useEffect, useRef } from 'react'\nimport { init } from '@waline/client'\nimport '@waline/client/style'\n\nexport function Waline({ serverURL }: { serverURL: string }) {\n  const ref = useRef<HTMLDivElement>(null)\n\n  useEffect(() => {\n    const walineInst = init({\n      el: ref.current,\n      serverURL,\n      dark: \"[data-theme='dark']\",\n      login: 'force',\n      imageUploader: false,\n      search: false,\n      locale: {\n        placeholder: '发条友善的评论吧（支持 Markdown 语法）…',\n      },\n      emoji: ['//unpkg.com/@waline/emojis@1.1.0/bilibili'],\n    })\n\n    return () => {\n      if (ref.current) {\n        walineInst?.destroy()\n      }\n    }\n  }, [serverURL])\n\n  return <div ref={ref}></div>\n}\n"
  },
  {
    "path": "src/components/comment/index.ts",
    "content": "export { default as Comments } from './Comments.astro'\n"
  },
  {
    "path": "src/components/footer/Footer.astro",
    "content": "---\nimport { ThemeSwitch } from './ThemeSwitch'\nimport { author, footer } from '@/config.json'\nimport { getAllPostsWordCount } from '@/utils/content'\nimport { RunningDays } from './RunningDays'\nimport Link from './Link.astro'\n\nconst sinceYear = new Date(footer.startTime).getFullYear()\nconst thisYear = new Date().getFullYear()\nconst copyDate = sinceYear === thisYear ? thisYear : `${sinceYear} - ${thisYear}`\n\nconst wordCount = await getAllPostsWordCount()\n\nconst wordCountStr = (wordCount / 1000).toFixed(1) + 'k'\n---\n\n<footer class=\"relative z-1 py-8 px-4 md:px-8 border-t border-primary text-secondary text-sm\">\n  <div class=\"text-center space-y-2\">\n    <div>\n      Powered by\n      <Link href=\"https://astro.build/\">Astro</Link>\n      & Designed by\n      <Link href=\"https://github.com/lxchapu/astro-gyoza\">Gyoza</Link>\n    </div>\n    <div class=\"space-x-1\">\n      <span>&copy;{copyDate} <Link href=\"/\">{author.name}</Link>.</span>\n      <Link href=\"/rss.xml\" data-no-swup>\n        <i class=\"iconfont icon-rss\"></i>\n        <span>RSS</span>\n      </Link>\n      <Link href=\"/sitemap-index.xml\" data-no-swup>\n        <i class=\"iconfont icon-map\"></i>\n        <span>站点地图</span>\n      </Link>\n    </div>\n    <div>\n      <RunningDays client:only=\"react\" />\n      <span class=\"select-none opacity-50\">|</span>\n      <span>共嘚嘚了 {wordCountStr} 字</span>\n    </div>\n  </div>\n  <div class=\"mt-4 flex justify-center\">\n    <ThemeSwitch client:only=\"react\" />\n  </div>\n</footer>\n"
  },
  {
    "path": "src/components/footer/Link.astro",
    "content": "---\nimport type { HTMLAttributes } from 'astro/types'\n\ninterface Props extends HTMLAttributes<'a'> {\n  href: string\n}\n\nconst { href, ...attrs } = Astro.props\n\nconst isExternal = href.startsWith('http')\n---\n\n<a\n  class=\"hover:text-accent\"\n  href={href}\n  target={isExternal ? '_blank' : undefined}\n  rel={isExternal ? 'noopener noreferrer' : undefined}\n  {...attrs}><slot /></a\n>\n"
  },
  {
    "path": "src/components/footer/RunningDays.tsx",
    "content": "import { useLayoutEffect, useState } from 'react'\nimport { footer } from '@/config.json'\nimport { getDiffInDays } from '@/utils/date'\n\nexport function RunningDays() {\n  const [days, setDays] = useState(0)\n\n  useLayoutEffect(() => {\n    const diffDays = getDiffInDays(new Date(footer.startTime))\n    setDays(diffDays)\n  }, [])\n\n  if (days < 0) {\n    return <span>Ops! 网站还没有发布</span>\n  }\n\n  return <span>已经运行了 {days} 天</span>\n}\n"
  },
  {
    "path": "src/components/footer/ThemeSwitch.tsx",
    "content": "import { themeAtom } from '@/store/theme'\nimport { useAtom } from 'jotai'\n\nexport function ThemeSwitch() {\n  const [theme, setTheme] = useAtom(themeAtom)\n\n  const left = { light: 4, system: 36, dark: 68 }[theme]\n\n  return (\n    <div className=\"relative inline-block\">\n      <div\n        className=\"absolute -z-1 top-1 size-[32px] rounded-full bg-primary transition-transform shadow\"\n        style={{\n          transform: `translateX(${left}px)`,\n        }}\n      ></div>\n      <div\n        className=\"p-[3px] flex rounded-full border border-primary\"\n        role=\"radiogroup\"\n      >\n        <button\n          className=\"size-[32px] flex items-center justify-center\"\n          type=\"button\"\n          aria-label=\"Switch to light theme\"\n          onClick={() => setTheme('light')}\n        >\n          <i className=\"iconfont icon-sun\"></i>\n        </button>\n        <button\n          className=\"size-[32px] flex items-center justify-center\"\n          type=\"button\"\n          aria-label=\"Switch to system theme\"\n          onClick={() => setTheme('system')}\n        >\n          <i className=\"iconfont icon-computer\"></i>\n        </button>\n        <button\n          className=\"size-[32px] flex items-center justify-center\"\n          type=\"button\"\n          aria-label=\"Switch to dark theme\"\n          onClick={() => setTheme('dark')}\n        >\n          <i className=\"iconfont icon-moon\"></i>\n        </button>\n      </div>\n    </div>\n  )\n}\n"
  },
  {
    "path": "src/components/head/AccentColorInjector.astro",
    "content": "<script>\n  import chroma from 'chroma-js'\n  import { color as themeColor } from '@/config.json'\n\n  function pickRandomAccent() {\n    const seed = (Math.random() * themeColor.accent.length) | 0\n    return themeColor.accent[seed]\n  }\n\n  function getRgbVal(color: chroma.Color) {\n    return color.rgb().join(' ')\n  }\n\n  function injectColor() {\n    const accentColor = pickRandomAccent()\n\n    const rootBgColor = {\n      light: chroma.mix('rgb(250,250,250)', accentColor.light, 0.05, 'rgb'),\n      dark: chroma.mix('rgb(0,2,18)', accentColor.dark, 0.12, 'rgb'),\n    }\n\n    const $style = document.createElement('style')\n    $style.textContent = `html {\n  --color-accent: ${getRgbVal(chroma(accentColor.light))};\n  --color-bg-root: ${getRgbVal(rootBgColor.light)};\n  --color-bg-primary: ${getRgbVal(chroma(themeColor.bg.primary.light))};\n  --color-bg-secondary: ${getRgbVal(chroma(themeColor.bg.secondary.light))};\n  --color-text-primary: ${getRgbVal(chroma(themeColor.text.primary.light))};\n  --color-text-secondary: ${getRgbVal(chroma(themeColor.text.secondary.light))};\n  --color-border-primary: ${getRgbVal(chroma(themeColor.border.primary.light))};\n}\n[data-theme='dark'] {\n  --color-accent: ${getRgbVal(chroma(accentColor.dark))};\n  --color-bg-root: ${getRgbVal(rootBgColor.dark)};\n  --color-bg-primary: ${getRgbVal(chroma(themeColor.bg.primary.dark))};\n  --color-bg-secondary: ${getRgbVal(chroma(themeColor.bg.secondary.dark))};\n  --color-text-primary: ${getRgbVal(chroma(themeColor.text.primary.dark))};\n  --color-text-secondary: ${getRgbVal(chroma(themeColor.text.secondary.dark))};\n  --color-border-primary: ${getRgbVal(chroma(themeColor.border.primary.dark))};\n}`\n    document.head.appendChild($style)\n  }\n\n  injectColor()\n\n  document.addEventListener('swup:content:replace', injectColor)\n</script>\n"
  },
  {
    "path": "src/components/head/CommonHead.astro",
    "content": "---\nimport { site, author } from '@/config.json'\n\ninterface Props {\n  title?: string\n  description?: string\n  image?: string\n}\n\nconst { title = site.title, description = site.description, image } = Astro.props\n\nconst titleWithSiteSuffix = title === site.title ? title : `${title} - ${site.title}`\n---\n\n<meta charset=\"utf-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n\n<link rel=\"apple-touch-icon\" sizes=\"180x180\" href={site.appleTouchIcon} />\n<link rel=\"icon\" href={site.favicon} />\n<!-- L'Internationale, \n  Sera le genre humain. -->\n<title>{titleWithSiteSuffix}</title>\n<meta name=\"author\" content={author.name} />\n<meta name=\"description\" content={description} />\n<meta name=\"keywords\" content={site.keywords} />\n<meta name=\"generator\" content={Astro.generator} />\n\n<meta property=\"og:url\" content={Astro.url} />\n<meta property=\"og:type\" content=\"website\" />\n<meta property=\"og:title\" content={title} />\n<meta property=\"og:description\" content={description} />\n{image && <meta property=\"og:image\" content={new URL(image, Astro.url)} />}\n\n<meta property=\"twitter:card\" content=\"summary_large_image\" />\n<meta property=\"twitter:title\" content={title} />\n<meta property=\"twitter:description\" content={description} />\n{author.twitterId && <meta property=\"twitter:site\" content={author.twitterId} />}\n{image && <meta property=\"twitter:image\" content={new URL(image, Astro.url)} />}\n\n<link rel=\"canonical\" href={new URL(Astro.url.pathname, Astro.site)} />\n<link rel=\"sitemap\" href=\"/sitemap-index.xml\" />\n<link\n  rel=\"alternate\"\n  type=\"application/rss+xml\"\n  title={site.title}\n  href={new URL('/rss.xml', Astro.url)}\n/>"
  },
  {
    "path": "src/components/head/PrintVersion.astro",
    "content": "<script>\n  import { version } from '@/../package.json'\n  \n  console.log(\n    `%c Gyoza ${version} %c https://gyoza.lxchapu.com `,\n    'color: #fff; margin: 1em 0; padding: 5px 0; background: #ef8f99;',\n    'margin: 1em 0; padding: 5px 0; background: #efefef;'\n  )\n</script>\n"
  },
  {
    "path": "src/components/head/ThemeLoader.astro",
    "content": "<script>\n  import { getLocalTheme, getSystemTheme, changePageTheme } from '@/utils/theme'\n\n  // 哀悼日\n  const MOURNING_DAYS = ['4-4', '5-12', '7-7', '9-18', '12-13']\n\n  function isMourningDay() {\n    const today = new Date()\n    const dateStr = `${today.getMonth() + 1}-${today.getDate()}`\n    return MOURNING_DAYS.includes(dateStr)\n  }\n\n  function load() {\n    const localTheme = getLocalTheme()\n    const systemTheme = getSystemTheme()\n    if (localTheme === 'system') {\n      changePageTheme(systemTheme)\n    } else {\n      changePageTheme(localTheme)\n    }\n    if (isMourningDay()) {\n      document.documentElement.classList.add('gray')\n    }\n  }\n\n  load()\n\n  // document.addEventListener('swup:content:replace', load)\n</script>\n"
  },
  {
    "path": "src/components/head/WebAnalytics.tsx",
    "content": "import { analytics } from '@/config.json'\n\nexport function WebAnalytics() {\n  if (import.meta.env.DEV || !analytics.enable) return null\n\n  return <>\n    {\n      analytics.umami.websiteId && <UmamiAnalytics {...analytics.umami} />\n    }\n    {\n      analytics.google.measurementId && <GoogleAnalytics {...analytics.google} />\n    }\n    {\n      analytics.microsoftClarity.projectId && <MicrosoftClarity {...analytics.microsoftClarity} />\n    }\n  </>\n}\n\nfunction UmamiAnalytics({\n  serverUrl,\n  websiteId,\n}: {\n  serverUrl?: string,\n  websiteId: string,\n}) {\n  const src = `${serverUrl || 'https://cloud.umami.is'}/script.js`\n\n  return <script defer src={src} data-website-id={websiteId} />\n}\n\n\nfunction GoogleAnalytics({\n  measurementId,\n}: {\n  measurementId: string,\n}) {\n  return (\n    <>\n      <script async src={`https://www.googletagmanager.com/gtag/js?id=${measurementId}`}></script>\n      <script dangerouslySetInnerHTML={{\n        __html: `window.dataLayer = window.dataLayer || [];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js', new Date());\n\ngtag('config', '${measurementId}');`,\n      }}></script>\n    </>\n  )\n}\n\n\nfunction MicrosoftClarity({\n  projectId,\n}: {\n  projectId: string,\n}) {\n  return (\n    <>\n      <script dangerouslySetInnerHTML={{\n        __html: `(function(c,l,a,r,i,t,y){\n            c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};\n            t=l.createElement(r);t.async=1;t.src=\"https://www.clarity.ms/tag/\"+i;\n            y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);\n          })(window, document, \"clarity\", \"script\", \"${projectId}\");`\n      }}></script>\n    </>\n  )\n}"
  },
  {
    "path": "src/components/head/index.ts",
    "content": "export { default as AccentColorInjector } from './AccentColorInjector.astro'\nexport { default as CommonHead } from './CommonHead.astro'\nexport { default as PrintVersion } from './PrintVersion.astro'\nexport { default as ThemeLoader } from './ThemeLoader.astro'\nexport { WebAnalytics } from './WebAnalytics'\n"
  },
  {
    "path": "src/components/head-gradient/HeadGradient.tsx",
    "content": "import { motion } from 'framer-motion'\n\nexport function HeadGradient() {\n  return (\n    <motion.div\n      className=\"absolute -z-1 top-0 inset-x-0 h-[350px] bg-gradient-to-r from-accent/5 to-accent/15\"\n      style={{\n        maskImage: 'linear-gradient(black, transparent)',\n      }}\n      initial={{ opacity: 0 }}\n      animate={{ opacity: 1 }}\n    ></motion.div>\n  )\n}\n"
  },
  {
    "path": "src/components/head-gradient/index.ts",
    "content": "export { HeadGradient } from './HeadGradient'\n"
  },
  {
    "path": "src/components/header/AnimatedLogo.tsx",
    "content": "import { AnimatePresence, motion } from 'framer-motion'\nimport { useShouldHeaderMetaShow, useIsMobile } from './hooks'\nimport { author } from '@/config.json'\n\nexport function AnimatedLogo() {\n  const isMobile = useIsMobile()\n  const shouldHeaderMetaShow = useShouldHeaderMetaShow()\n\n  if (!isMobile) {\n    return <Logo />\n  }\n\n  return (\n    <AnimatePresence>\n      {!shouldHeaderMetaShow && (\n        <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}>\n          <Logo />\n        </motion.div>\n      )}\n    </AnimatePresence>\n  )\n}\n\nfunction Logo() {\n  return (\n    <a className=\"block\" href=\"/\" title=\"Nav to home\">\n      <img\n        className=\"size-[40px] select-none object-cover rounded-2xl\"\n        src={author.avatar}\n        alt=\"Site owner avatar\"\n      />\n    </a>\n  )\n}\n"
  },
  {
    "path": "src/components/header/BluredBackground.tsx",
    "content": "import { useHeaderBgOpacity } from './hooks'\n\nexport function BluredBackground() {\n  const opacity = useHeaderBgOpacity()\n\n  return (\n    <div\n      className=\"absolute inset-0 -z-1 border-b border-primary bg-white/70 dark:bg-zinc-800/70 backdrop-saturate-150 backdrop-blur-lg transform-gpu\"\n      style={{\n        opacity,\n      }}\n    ></div>\n  )\n}\n"
  },
  {
    "path": "src/components/header/Header.tsx",
    "content": "import { BluredBackground } from './BluredBackground'\nimport { HeaderContent } from './HeaderContent'\nimport { SearchButton } from './SearchButton'\nimport { AnimatedLogo } from './AnimatedLogo'\nimport { HeaderMeta } from './HeaderMeta'\nimport { HeaderDrawer } from './HeaderDrawer'\nimport { useIsMobile } from './hooks'\n\nexport function Header() {\n  const isMobile = useIsMobile()\n\n  return (\n    <header className=\"fixed top-0 inset-x-0 h-[64px] z-10 overflow-hidden\">\n      <BluredBackground />\n      <div className=\"max-w-[1100px] h-full md:px-4 mx-auto grid grid-cols-[64px_auto_64px]\">\n        <div className=\"flex items-center justify-center\">\n          {isMobile ? <HeaderDrawer /> : <AnimatedLogo />}\n        </div>\n        <div className=\"relative flex items-center justify-center\">\n          {isMobile ? <AnimatedLogo /> : <HeaderContent />}\n          <HeaderMeta />\n        </div>\n        <div className=\"flex items-center justify-center\">\n          <SearchButton />\n        </div>\n      </div>\n    </header>\n  )\n}\n"
  },
  {
    "path": "src/components/header/HeaderContent.tsx",
    "content": "import { useState } from 'react'\nimport { menus } from '@/config.json'\nimport { clsx } from 'clsx'\nimport { AnimatePresence, motion } from 'framer-motion'\nimport {\n  usePathName,\n  useShouldAccessibleMenuShow,\n  useShouldHeaderMenuBgShow,\n  useShouldHeaderMetaShow,\n} from './hooks'\nimport { RootPortal } from '@/components/RootPortal'\n\nexport function HeaderContent() {\n  return (\n    <>\n      <AnimatedMenu />\n      <AccessibleMenu />\n    </>\n  )\n}\n\nfunction AnimatedMenu() {\n  const shouldBgShow = useShouldHeaderMenuBgShow()\n  const shouldHeaderMetaShow = useShouldHeaderMetaShow()\n\n  return (\n    <AnimatePresence>\n      {!shouldHeaderMetaShow && (\n        <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}>\n          <HeaderMenu isBgShow={shouldBgShow} />\n        </motion.div>\n      )}\n    </AnimatePresence>\n  )\n}\n\nfunction AccessibleMenu() {\n  const shouldShow = useShouldAccessibleMenuShow()\n\n  return (\n    <RootPortal>\n      <AnimatePresence>\n        {shouldShow && (\n          <motion.div\n            className=\"fixed z-10 top-12 inset-x-0 flex justify-center pointer-events-none\"\n            initial={{ y: -20 }}\n            animate={{ y: 0 }}\n            exit={{ y: -20, opacity: 0 }}\n          >\n            <HeaderMenu isBgShow />\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </RootPortal>\n  )\n}\n\nfunction HeaderMenu({ isBgShow }: { isBgShow: boolean }) {\n  const pathName = usePathName()\n  const [mouseX, setMouseX] = useState(0)\n  const [mouseY, setMouseY] = useState(0)\n  const [radius, setRadius] = useState(0)\n\n  const background = `radial-gradient(${radius}px circle at ${mouseX}px ${mouseY}px, rgb(var(--color-accent) / 0.12) 0%, transparent 65%)`\n\n  const handleMouseMove = ({ clientX, clientY, currentTarget }: React.MouseEvent) => {\n    const bounds = currentTarget.getBoundingClientRect()\n    setMouseX(clientX - bounds.left)\n    setMouseY(clientY - bounds.top)\n    setRadius(Math.sqrt(bounds.width ** 2 + bounds.height ** 2) / 2.5)\n  }\n\n  return (\n    <nav\n      className={clsx('relative rounded-full group pointer-events-auto duration-200', {\n        'bg-gradient-to-b from-zinc-50/70 to-white/90 shadow-lg shadow-zinc-800/5 ring-1 ring-zinc-900/5 backdrop-blur-md dark:from-zinc-900/70 dark:to-zinc-800/90 dark:ring-zinc-100/10':\n          isBgShow,\n      })}\n      onMouseMove={handleMouseMove}\n    >\n      <div\n        className=\"absolute -z-1 -inset-px rounded-full opacity-0 group-hover:opacity-100 duration-500\"\n        style={{ background }}\n        aria-hidden\n      ></div>\n      <div className=\"text-sm px-4 flex\">\n        {menus.map((menu) => (\n          <HeaderMenuItem\n            key={menu.name}\n            href={menu.link}\n            title={menu.name}\n            icon={menu.icon}\n            isActive={pathName === menu.link}\n          />\n        ))}\n      </div>\n    </nav>\n  )\n}\n\nfunction HeaderMenuItem({\n  href,\n  isActive,\n  title,\n  icon,\n}: {\n  href: string\n  isActive: boolean\n  title: string\n  icon: string\n}) {\n  return (\n    <a\n      className={clsx('relative block px-4 py-1.5', isActive ? 'text-accent' : 'hover:text-accent')}\n      href={href}\n    >\n      <div className=\"flex space-x-2\">\n        {isActive && (\n          <motion.i\n            className={clsx('iconfont', icon)}\n            initial={{ y: 10, opacity: 0 }}\n            animate={{ y: 0, opacity: 1 }}\n          ></motion.i>\n        )}\n        <span>{title}</span>\n      </div>\n      {isActive && (\n        <div className=\"absolute inset-x-0 bottom-0 h-px bg-gradient-to-r from-transparent via-accent/70 to-transparent\"></div>\n      )}\n    </a>\n  )\n}\n"
  },
  {
    "path": "src/components/header/HeaderDrawer.tsx",
    "content": "import { menus } from '@/config.json'\nimport { createContext, useContext, useState, forwardRef } from 'react'\nimport * as Dialog from '@radix-ui/react-dialog'\nimport { motion, AnimatePresence } from 'framer-motion'\nimport clsx from 'clsx'\n\nconst contentVariants = {\n  hidden: {\n    x: '-100%',\n    transition: {\n      duration: 0.2,\n      ease: 'easeOut',\n    },\n  },\n  visible: {\n    x: 0,\n    transition: {\n      staggerChildren: 0.1,\n      delayChildren: 0.1,\n      duration: 0.2,\n      ease: 'easeOut',\n    },\n  },\n}\n\nconst menuItemVariants = {\n  hidden: {\n    opacity: 0,\n    x: '-100%',\n  },\n  visible: {\n    opacity: 1,\n    x: 0,\n  },\n}\n\nexport function HeaderDrawer({ zIndex = 999 }: { zIndex?: number }) {\n  const [isOpen, setIsOpen] = useState(false)\n  const overlayZIndex = zIndex - 1\n  const contentZIndex = zIndex\n\n  return (\n    <Dialog.Root open={isOpen} onOpenChange={setIsOpen}>\n      <Dialog.Trigger asChild>\n        <TriggerButton />\n      </Dialog.Trigger>\n\n      <AnimatePresence>\n        {isOpen && (\n          <Dialog.Portal forceMount>\n            <Dialog.Overlay asChild>\n              <motion.div\n                className=\"fixed inset-0 bg-gray-800/40\"\n                style={{ zIndex: overlayZIndex }}\n                initial={{ opacity: 0 }}\n                animate={{ opacity: 1 }}\n                exit={{ opacity: 0, transition: { delay: 0.1 } }}\n              ></motion.div>\n            </Dialog.Overlay>\n\n            <Dialog.Content asChild>\n              <motion.div\n                className=\"fixed left-0 inset-y-0 h-full bg-primary rounded-r-lg p-4 flex flex-col justify-center w-[260px] max-w-[80%]\"\n                style={{ zIndex: contentZIndex }}\n                variants={contentVariants}\n                initial=\"hidden\"\n                animate=\"visible\"\n                exit=\"hidden\"\n              >\n                <DrawerContext.Provider\n                  value={{\n                    dismiss() {\n                      setIsOpen(false)\n                    },\n                  }}\n                >\n                  <DrawerContentImpl />\n                </DrawerContext.Provider>\n              </motion.div>\n            </Dialog.Content>\n          </Dialog.Portal>\n        )}\n      </AnimatePresence>\n    </Dialog.Root>\n  )\n}\n\nconst TriggerButton = forwardRef<HTMLButtonElement>((props, ref) => {\n  return (\n    <button\n      ref={ref}\n      className=\"size-9 rounded-full shadow-lg shadow-zinc-800/5 border border-primary bg-white/50 dark:bg-zinc-800/50 backdrop-blur\"\n      type=\"button\"\n      aria-label=\"Open menu\"\n      {...props}\n    >\n      <i className=\"iconfont icon-menu\"></i>\n    </button>\n  )\n})\n\nfunction DrawerContentImpl() {\n  const { dismiss } = useContext(DrawerContext)\n\n  return (\n    <ul className=\"mt-8 pb-8 overflow-y-auto overflow-x-hidden min-h-0\">\n      {menus.map((menu) => (\n        <motion.li key={menu.name} variants={menuItemVariants}>\n          <a className=\"inline-flex p-2 space-x-4\" href={menu.link} onClick={dismiss}>\n            <i className={clsx('iconfont', menu.icon)}></i>\n            <span>{menu.name}</span>\n          </a>\n        </motion.li>\n      ))}\n    </ul>\n  )\n}\n\nconst DrawerContext = createContext<{ dismiss(): void }>(null!)\n"
  },
  {
    "path": "src/components/header/HeaderMeta.tsx",
    "content": "import { site } from '@/config.json'\nimport { AnimatePresence, motion } from 'framer-motion'\nimport { useHeaderMetaInfo, useShouldHeaderMetaShow } from './hooks'\n\nexport function HeaderMeta() {\n  const { title, description, slug } = useHeaderMetaInfo()\n  const shouldShow = useShouldHeaderMetaShow()\n\n  return (\n    <AnimatePresence>\n      {shouldShow && (\n        <motion.div\n          className=\"absolute inset-0 z-1 flex items-center justify-between md:px-10\"\n          initial={{\n            opacity: 0,\n            y: 20,\n          }}\n          animate={{\n            opacity: 1,\n            y: 0,\n          }}\n          exit={{\n            opacity: 0,\n            y: 20,\n          }}\n        >\n          <div className=\"grow min-w-0\">\n            <div className=\"text-secondary text-xs truncate\">{description}</div>\n            <h2 className=\"truncate text-lg\">{title}</h2>\n          </div>\n          <div className=\"hidden md:block min-w-0 text-right\">\n            <div className=\"text-secondary text-xs truncate\">{slug}</div>\n            <div>{site.title}</div>\n          </div>\n        </motion.div>\n      )}\n    </AnimatePresence>\n  )\n}\n"
  },
  {
    "path": "src/components/header/SearchButton.tsx",
    "content": "import { motion } from 'framer-motion'\nimport { useCurrentModal, useModal } from '@/components/ui/modal'\nimport { useEffect, useState } from 'react'\nimport { useDebounceValue } from '@/hooks/useDebounceValue'\n\nlet pagefind: any = null\nasync function loadPagefind() {\n  if (import.meta.env.PROD && !pagefind) {\n    const url = '/pagefind/pagefind.js'\n    pagefind = await import(/* @vite-ignore */ url)\n  }\n}\n\nexport function SearchButton() {\n  const { present } = useModal()\n\n  const openModal = () => {\n    present({\n      content: <SearchPanel />,\n    })\n  }\n\n  useSearchKeyboardEvents({ onOpen: openModal })\n\n  return (\n    <button\n      className=\"size-9 rounded-full shadow-lg shadow-zinc-800/5 border border-primary bg-white/50 dark:bg-zinc-800/50 backdrop-blur\"\n      type=\"button\"\n      aria-label=\"Search\"\n      onClick={openModal}\n    >\n      <i className=\"iconfont icon-search\"></i>\n    </button>\n  )\n}\n\nfunction SearchPanel() {\n  const [keyword, setKeyword] = useState('')\n  const [isLoading, setIsLoading] = useState(false)\n  const [results, setResults] = useState<any[]>([])\n  const debouncedKeyword = useDebounceValue(keyword, 350)\n\n  const { dismiss } = useCurrentModal()\n\n  async function search(value: string) {\n    if (!value) {\n      setResults([])\n      return\n    }\n    setIsLoading(true)\n    await loadPagefind()\n    if (pagefind) {\n      const res = await pagefind.search(value)\n      const nextResults = await Promise.all(res.results.map((r: any) => r.data()))\n      setResults(nextResults)\n    }\n    setIsLoading(false)\n  }\n\n  useEffect(() => {\n    search(debouncedKeyword)\n  }, [debouncedKeyword])\n\n  let resultList = null\n  if (import.meta.env.DEV) {\n    resultList = (\n      <div className=\"h-full flex items-center justify-center\">\n        <div className=\"flex gap-2\">\n          <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"2em\" viewBox=\"0 0 24 24\">\n            <path\n              fill=\"currentColor\"\n              d=\"M4 20v-6a8 8 0 1 1 16 0v6h1v2H3v-2zm2 0h12v-6a6 6 0 0 0-12 0zm5-18h2v3h-2zm8.778 2.808l1.414 1.414l-2.12 2.121l-1.415-1.414zM2.808 6.222l1.414-1.414l2.121 2.12L4.93 8.344zM7 14a5 5 0 0 1 5-5v2a3 3 0 0 0-3 3z\"\n            />\n          </svg>\n          <div>\n            <div className=\"font-semibold mb-1\">抱歉</div>\n            <div className=\"text-sm\">该功能基于 pagefind，请在构建后再次尝试。</div>\n          </div>\n        </div>\n      </div>\n    )\n  } else if (isLoading) {\n    resultList = (\n      <div className=\"h-full flex items-center justify-center\">\n        <svg\n          xmlns=\"http://www.w3.org/2000/svg\"\n          width=\"2em\"\n          viewBox=\"0 0 24 24\"\n          className=\"animate-spin\"\n        >\n          <path\n            fill=\"currentColor\"\n            d=\"M12 2a1 1 0 0 1 1 1v3a1 1 0 1 1-2 0V3a1 1 0 0 1 1-1m0 15a1 1 0 0 1 1 1v3a1 1 0 1 1-2 0v-3a1 1 0 0 1 1-1m8.66-10a1 1 0 0 1-.366 1.366l-2.598 1.5a1 1 0 1 1-1-1.732l2.598-1.5A1 1 0 0 1 20.66 7M7.67 14.5a1 1 0 0 1-.367 1.366l-2.598 1.5a1 1 0 1 1-1-1.732l2.598-1.5a1 1 0 0 1 1.366.366M20.66 17a1 1 0 0 1-1.366.366l-2.598-1.5a1 1 0 0 1 1-1.732l2.598 1.5A1 1 0 0 1 20.66 17M7.67 9.5a1 1 0 0 1-1.367.366l-2.598-1.5a1 1 0 1 1 1-1.732l2.598 1.5A1 1 0 0 1 7.67 9.5\"\n          />\n        </svg>\n      </div>\n    )\n  } else if (keyword.length === 0) {\n    resultList = (\n      <div className=\"h-full flex items-center justify-center\">\n        <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"2em\" viewBox=\"0 0 24 24\">\n          <path\n            fill=\"currentColor\"\n            d=\"m18.031 16.617l4.283 4.282l-1.415 1.415l-4.282-4.283A8.96 8.96 0 0 1 11 20c-4.968 0-9-4.032-9-9s4.032-9 9-9s9 4.032 9 9a8.96 8.96 0 0 1-1.969 5.617m-2.006-.742A6.98 6.98 0 0 0 18 11c0-3.867-3.133-7-7-7s-7 3.133-7 7s3.133 7 7 7a6.98 6.98 0 0 0 4.875-1.975z\"\n          />\n        </svg>\n      </div>\n    )\n  } else if (results.length === 0) {\n    resultList = (\n      <div className=\"h-full flex items-center justify-center\">\n        <div className=\"flex flex-col items-center gap-2\">\n          <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"2em\" viewBox=\"0 0 24 24\">\n            <path\n              fill=\"currentColor\"\n              d=\"M11 11v2l-5.327 6H11v2H3v-2l5.326-6H3v-2zm10-8v2l-5.327 6H21v2h-8v-2l5.326-6H13V3z\"\n            />\n          </svg>\n          <div>无内容</div>\n        </div>\n      </div>\n    )\n  } else {\n    resultList = (\n      <>\n        <div className=\"text-sm px-3 mb-2\">找到以下 {results.length} 条结果</div>\n        {results.map((item) => {\n          return (\n            <a\n              href={item.url}\n              key={item.url}\n              className=\"hover:bg-accent/10 rounded block px-3 py-2\"\n              onClick={dismiss}\n            >\n              <div className=\"font-semibold\">{item.meta.title}</div>\n              <p className=\"text-sm\" dangerouslySetInnerHTML={{ __html: item.excerpt }}></p>\n            </a>\n          )\n        })}\n      </>\n    )\n  }\n\n  return (\n    <motion.div\n      className=\"bg-primary rounded-lg w-[90vw] h-[80vh] max-w-[680px] max-h-[480px] border border-primary flex flex-col\"\n      initial={{ y: 20, opacity: 0 }}\n      animate={{ y: 0, opacity: 1 }}\n      exit={{ y: 20, opacity: 0 }}\n    >\n      <input\n        className=\"px-4 py-3 outline-none bg-transparent border-b border-primary\"\n        type=\"text\"\n        placeholder=\"Search...\"\n        maxLength={64}\n        value={keyword}\n        onChange={(e) => setKeyword(e.target.value)}\n      />\n      <div className=\"px-4 py-3 overflow-y-auto grow\">{resultList}</div>\n      <div className=\"px-3 py-2 flex justify-end\">\n        <a\n          href=\"https://pagefind.app/\"\n          target=\"_blank\"\n          rel=\"noopener noreferrer\"\n          className=\"flex items-center \"\n        >\n          <span className=\"mr-2 text-xs\">Search by</span>\n          <span className=\"font-semibold\">pagefind</span>\n        </a>\n      </div>\n    </motion.div>\n  )\n}\n\nfunction useSearchKeyboardEvents({ onOpen }: { onOpen: () => void }) {\n  useEffect(() => {\n    function handleKeyDown(event: KeyboardEvent) {\n      if (event.key.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey)) {\n        event.preventDefault()\n        onOpen()\n      }\n    }\n\n    window.addEventListener('keydown', handleKeyDown)\n\n    return () => {\n      window.removeEventListener('keydown', handleKeyDown)\n    }\n  }, [onOpen])\n}\n"
  },
  {
    "path": "src/components/header/hooks.ts",
    "content": "import { useAtomValue } from 'jotai'\nimport {\n  pathNameAtom,\n  metaTitleAtom,\n  metaDescriptionAtom,\n  metaSlugAtom,\n  hasMetaInfoAtom,\n} from '@/store/metaInfo'\nimport { pageScrollLocationAtom, pageScrollDirectionAtom } from '@/store/scrollInfo'\nimport { isMobileAtom } from '@/store/viewport'\nimport { floor } from 'lodash-es'\n\nconst threshold = 60\n\nexport function useHeaderBgOpacity() {\n  const scrollY = useAtomValue(pageScrollLocationAtom)\n  if (scrollY >= threshold * 2) {\n    return 1\n  } else if (scrollY <= threshold) {\n    return 0\n  } else {\n    return floor((scrollY - threshold) / threshold, 2)\n  }\n}\n\nexport function useHasMetaInfo() {\n  return useAtomValue(hasMetaInfoAtom)\n}\n\nexport function useShouldHeaderMenuBgShow() {\n  const scrollY = useAtomValue(pageScrollLocationAtom)\n  return scrollY < threshold\n}\n\nexport function useIsMobile() {\n  return useAtomValue(isMobileAtom)\n}\n\nexport function useShouldHeaderMetaShow() {\n  const hasMetaInfo = useHasMetaInfo()\n  const scrollY = useAtomValue(pageScrollLocationAtom)\n\n  return hasMetaInfo && scrollY >= threshold\n}\n\nexport function useHeaderMetaInfo() {\n  const title = useAtomValue(metaTitleAtom)\n  const description = useAtomValue(metaDescriptionAtom)\n  const slug = useAtomValue(metaSlugAtom)\n\n  return {\n    title,\n    description,\n    slug,\n  }\n}\n\nexport function usePathName() {\n  return useAtomValue(pathNameAtom)\n}\n\nexport function useShouldAccessibleMenuShow() {\n  const scrollY = useAtomValue(pageScrollLocationAtom)\n  const scrollDirection = useAtomValue(pageScrollDirectionAtom)\n  const hasMetaInfo = useHasMetaInfo()\n\n  return hasMetaInfo && scrollY >= 400 && scrollDirection === 'up'\n}\n"
  },
  {
    "path": "src/components/hero/Hero.astro",
    "content": "---\nimport { hero, author } from '@/config.json'\nimport { SocialList } from './SocialList'\nimport Highlight from '@/components/Highlight.astro'\n---\n\n<div class=\"lg:-mt-16 lg:h-dvh lg:min-h-[720px]\">\n  <div\n    class=\"relative max-w-[1300px] mx-auto h-full px-4 grid lg:grid-cols-2 items-center justify-items-center\"\n  >\n    <div class=\"mt-[120px] lg:mt-0 max-w-[590px]\">\n      <h1 class=\"text-3xl text-center lg:text-left text-balance\">\n        Hi there, I'm <Highlight class=\"font-bold\">{hero.name}</Highlight>👋<br />{hero.bio}\n      </h1>\n      <div class=\"text-sm text-secondary mt-3 text-center lg:text-left\">{hero.description}</div>\n      <SocialList className=\"mt-[60px]\" client:load />\n    </div>\n    <div class=\"mt-20 lg:mt-0\">\n      <div\n        class=\"size-[200px] lg:size-[300px] rounded-full overflow-hidden border border-primary bg-zinc-100 dark:bg-zinc-800\"\n      >\n        <img class=\"size-full\" src={author.avatar} alt=\"Site owner avatar\" loading=\"lazy\" />\n      </div>\n    </div>\n\n    <div class=\"mt-10 lg:mt-0 lg:absolute inset-x-0 bottom-0 flex flex-col items-center\">\n      <p class=\"text-xs text-center text-balance text-secondary\">\n        {hero.yiyan}\n      </p>\n      <div class=\"mt-7 text-xl animate-bounce\">\n        <i class=\"iconfont icon-down\"></i>\n      </div>\n    </div>\n  </div>\n</div>\n"
  },
  {
    "path": "src/components/hero/SocialList.tsx",
    "content": "import clsx from 'clsx'\nimport { hero } from '@/config.json'\nimport { motion } from 'framer-motion'\n\nconst itemVariants = {\n  hidden: {\n    opacity: 0,\n    y: 40,\n  },\n  visible: {\n    opacity: 1,\n    y: 0,\n  },\n}\n\nexport function SocialList({ className }: { className?: string }) {\n  return (\n    <motion.ul\n      className={clsx(\n        'flex gap-4 flex-wrap items-center justify-center lg:justify-start',\n        className,\n      )}\n      initial=\"hidden\"\n      animate=\"visible\"\n      transition={{\n        staggerChildren: 0.1,\n      }}\n    >\n      {hero.socials.map((social) => (\n        <motion.li key={social.name} variants={itemVariants}>\n          <a\n            className=\"relative size-9 text-white text-xl flex justify-center items-center group\"\n            href={social.url}\n            title={social.name}\n            target=\"_blank\"\n            rel=\"noopener noreferrer\"\n          >\n            <span\n              className=\"absolute inset-0 -z-1 rounded-full group-hover:scale-105 transition\"\n              style={{ backgroundColor: social.color }}\n            ></span>\n            <i className={clsx('iconfont', social.icon)} />\n          </a>\n        </motion.li>\n      ))}\n    </motion.ul>\n  )\n}\n"
  },
  {
    "path": "src/components/post/ActionAside.tsx",
    "content": "import { sponsor, site } from '@/config.json'\nimport { motion } from 'framer-motion'\nimport * as QR from 'qrcode.react'\nimport { useAtomValue } from 'jotai'\nimport { metaSlugAtom, metaTitleAtom } from '@/store/metaInfo'\nimport clsx from 'clsx'\nimport { toast } from 'react-toastify'\nimport { useModal } from '@/components/ui/modal'\n\ninterface ShareData {\n  url: string\n  text: string\n}\n\nconst shareList = [\n  {\n    name: 'Twitter',\n    icon: 'icon-x',\n    onClick: (data: ShareData) => {\n      window.open(\n        `https://twitter.com/intent/tweet?url=${encodeURIComponent(data.url)}&text=${encodeURIComponent(data.text)}&via=${encodeURIComponent(site.title)}`,\n      )\n    },\n  },\n  {\n    name: '复制链接',\n    icon: 'icon-link',\n    onClick: (data: ShareData) => {\n      navigator.clipboard.writeText(data.url)\n      toast.success('已复制到剪贴板')\n    },\n  },\n]\n\nexport function ActionAside() {\n  return (\n    <div\n      className=\"absolute left-0 bottom-0 flex flex-col gap-4\"\n      style={{\n        transform: 'translateY(calc(100% + 24px))',\n      }}\n    >\n      <ShareButton />\n      <DonateButton />\n    </div>\n  )\n}\n\nfunction ShareButton() {\n  const postSlug = useAtomValue(metaSlugAtom)\n  const postTitle = useAtomValue(metaTitleAtom)\n  const { present } = useModal()\n\n  const url = new URL(postSlug, site.url).href\n  const text = `嘿，我发现了一片宝藏文章「${postTitle}」哩，快来看看吧！`\n\n  const openModal = () => {\n    present({\n      content: <ShareModal url={url} text={text} />,\n    })\n  }\n\n  return (\n    <button\n      type=\"button\"\n      aria-label=\"Share this post\"\n      className=\"size-6 text-xl leading-none hover:text-accent\"\n      onClick={() => openModal()}\n    >\n      <i className=\"iconfont icon-share\"></i>\n    </button>\n  )\n}\n\nfunction ShareModal({ url, text }: { url: string; text: string }) {\n  return (\n    <motion.div\n      className=\"bg-primary rounded-lg p-2 min-w-[420px] border border-primary flex flex-col\"\n      initial={{ opacity: 0, scale: 0.8 }}\n      animate={{ opacity: 1, scale: 1 }}\n      exit={{ opacity: 0, scale: 0.8 }}\n    >\n      <h2 className=\"px-3 py-1 font-bold\">分享此内容</h2>\n      <hr className=\"my-2 border-primary\" />\n      <div className=\"px-3 py-2 grid grid-cols-[180px_auto] gap-3\">\n        <QR.QRCodeSVG value={url} size={180} />\n        <div className=\"flex flex-col gap-2\">\n          <div className=\"text-sm\">分享到...</div>\n          <ul className=\"flex flex-col gap-2\">\n            {shareList.map((item) => (\n              <li\n                className=\"px-2 py-1 flex gap-2 cursor-pointer rounded-md hover:bg-secondary\"\n                key={item.name}\n                onClick={() => item.onClick({ url, text })}\n                role=\"button\"\n                aria-label={`Share to ${item.name}`}\n              >\n                <i className={clsx('iconfont text-accent', item.icon)}></i>\n                <span>{item.name}</span>\n              </li>\n            ))}\n          </ul>\n        </div>\n      </div>\n    </motion.div>\n  )\n}\n\nfunction DonateButton() {\n  const { present } = useModal()\n\n  const openDonate = () => {\n    present({\n      content: <DonateContent />,\n    })\n  }\n\n  return (\n    <button\n      type=\"button\"\n      aria-label=\"Donate to author\"\n      className=\"size-6 text-xl leading-none hover:text-accent\"\n      onClick={() => openDonate()}\n    >\n      <i className=\"iconfont icon-user-heart\"></i>\n    </button>\n  )\n}\n\nfunction DonateContent() {\n  return (\n    <motion.div\n      initial={{ y: 20, opacity: 0 }}\n      animate={{ y: 0, opacity: 1 }}\n      exit={{ y: 20, opacity: 0 }}\n    >\n      <h2 className=\"text-center mb-5\">感谢您的支持，这将成为我前进的最大动力。</h2>\n      <div className=\"flex flex-wrap gap-4 justify-center\">\n        <img\n          className=\"object-cover\"\n          width={300}\n          height={300}\n          src={sponsor.wechat}\n          alt=\"微信赞赏码\"\n          loading=\"lazy\"\n          decoding=\"async\"\n        />\n      </div>\n    </motion.div>\n  )\n}\n"
  },
  {
    "path": "src/components/post/Outdate.tsx",
    "content": "import { useEffect, useState } from 'react'\nimport { getDiffInDays, getFormattedDate } from '@/utils/date'\nimport { motion, AnimatePresence } from 'framer-motion'\n\nexport function Outdate({ lastMod }: { lastMod: Date }) {\n  const [isShow, setIsShow] = useState(false)\n\n  useEffect(() => {\n    const diffDays = getDiffInDays(lastMod)\n    if (diffDays > 30) {\n      setIsShow(true)\n    }\n  }, [lastMod])\n\n  return (\n    <AnimatePresence>\n      {isShow && (\n        <motion.div\n          className=\"flex justify-center text-sm p-4 rounded-lg bg-amber-300/10 border border-amber-300\"\n          initial={{ opacity: 0 }}\n          animate={{ opacity: 1 }}\n          exit={{ opacity: 0 }}\n        >\n          <span>\n            这篇文章最后修改于 {getFormattedDate(lastMod)}\n            ，部分内容可能已经不适用，如有疑问可联系作者。\n          </span>\n        </motion.div>\n      )}\n    </AnimatePresence>\n  )\n}\n"
  },
  {
    "path": "src/components/post/PostArchiveInfo.astro",
    "content": "---\nimport { slugify } from '@/utils/content'\n\ninterface Props {\n  tags: string[]\n  category?: string\n  class?: string\n}\n\nconst { tags, category, class: className } = Astro.props\n---\n\n<div class=\"flex flex-wrap gap-2 text-sm text-secondary\" class:list={[className]}>\n  {\n    category && (\n      <div>\n        <i class=\"iconfont icon-folder\" />\n        <a\n          class=\"hover:text-accent hover:underline underline-offset-2 decoration-dashed\"\n          href={`/categories/${slugify(category)}`}\n        >\n          {category}\n        </a>\n      </div>\n    )\n  }\n  {\n    tags.length > 0 && (\n      <div>\n        <i class=\"iconfont icon-hashtag\" />\n        {tags.map((tag, index) => (\n          <>\n            {index > 0 && <span>, </span>}\n            <a\n              class=\"hover:text-accent hover:underline underline-offset-2 decoration-dashed\"\n              href={`/tags/${slugify(tag)}`}\n            >\n              {tag}\n            </a>\n          </>\n        ))}\n      </div>\n    )\n  }\n</div>\n"
  },
  {
    "path": "src/components/post/PostCard.astro",
    "content": "---\nimport type { CollectionEntry } from 'astro:content'\nimport { PostCardHoverOverlay } from './PostCardHoverOverlay'\nimport PostMetaInfo from './PostMetaInfo.astro'\n\ninterface Props {\n  entry: CollectionEntry<'posts'>\n}\n\nconst { entry } = Astro.props\n\nconst { remarkPluginFrontmatter } = await entry.render()\n---\n\n<a class=\"block relative py-8 focus-visible:outline-0\" href={`/posts/${entry.slug}`}>\n  <PostCardHoverOverlay client:only=\"react\" />\n  <h2 class=\"relative text-2xl font-bold\">\n    {entry.data.title}\n    {\n      entry.data.sticky > 0 && (\n        <i class=\"absolute right-0 top-0 z-10 size-6 leading-none iconfont icon-pushpin text-red-500\" />\n      )\n    }\n  </h2>\n  <div class=\"mt-4 overflow-hidden\">\n    {\n      entry.data.cover && (\n        <img\n          class=\"float-right ml-3 mb-2 size-[80px] rounded-md object-cover select-none\"\n          src={entry.data.cover}\n          alt={entry.data.title}\n          loading=\"lazy\"\n        />\n      )\n    }\n    {entry.data.summary && <p>{entry.data.summary}</p>}\n  </div>\n  <div class=\"mt-2 flex flex-wrap items-center justify-end gap-4 select-none\">\n    <PostMetaInfo\n      class=\"grow\"\n      date={entry.data.date}\n      lastMod={entry.data.lastMod}\n      words={remarkPluginFrontmatter.words}\n      readingMinutes={remarkPluginFrontmatter.readingMinutes}\n    />\n    <div class=\"group shrink-0 text-accent flex items-center gap-2\">\n      <span>继续阅读</span>\n      <svg width=\"36\" height=\"12\" viewBox=\"0 0 36 12\" fill=\"none\" class=\"stroke-current\">\n        <path\n          d=\"M0.75 6H11.25 M6 0.75L11.25 6L6 11.25\"\n          stroke-linecap=\"round\"\n          stroke-linejoin=\"round\"></path>\n        <path\n          d=\"M15 10L19.5 5.5L15 1\"\n          stroke-linecap=\"round\"\n          stroke-linejoin=\"round\"\n          class=\"delay-100 opacity-0 group-hover:opacity-100\"></path>\n        <path\n          d=\"M23 10L27.5 5.5L23 1\"\n          stroke-opacity=\"0.66\"\n          stroke-linecap=\"round\"\n          stroke-linejoin=\"round\"\n          class=\"delay-200 opacity-0 group-hover:opacity-100\"></path>\n        <path\n          d=\"M31 10L35.5 5.5L31 1\"\n          stroke-opacity=\"0.35\"\n          stroke-linecap=\"round\"\n          stroke-linejoin=\"round\"\n          class=\"delay-300 opacity-0 group-hover:opacity-100\"></path>\n      </svg>\n    </div>\n  </div>\n</a>\n"
  },
  {
    "path": "src/components/post/PostCardHoverOverlay.tsx",
    "content": "import { AnimatePresence, motion } from 'framer-motion'\nimport { useEffect, useRef, useState } from 'react'\n\nexport function PostCardHoverOverlay() {\n  const ref = useRef<HTMLDivElement>(null)\n  const [enter, setEnter] = useState(false)\n\n  const handleMouseEnter = () => {\n    setEnter(true)\n  }\n  const handleMouseLeave = () => {\n    setEnter(false)\n  }\n  const handleFocus = () => {\n    setEnter(true)\n  }\n  const handleBlur = () => {\n    setEnter(false)\n  }\n\n  useEffect(() => {\n    const $ref = ref.current\n    if (!$ref) return\n    const $parent = $ref.parentElement?.parentElement\n    if (!$parent) return\n\n    $parent.addEventListener('mouseenter', handleMouseEnter)\n    $parent.addEventListener('mouseleave', handleMouseLeave)\n    $parent.addEventListener('focus', handleFocus)\n    $parent.addEventListener('blur', handleBlur)\n\n    return () => {\n      $parent.removeEventListener('mouseenter', handleMouseEnter)\n      $parent.removeEventListener('mouseleave', handleMouseLeave)\n      $parent.removeEventListener('focus', handleFocus)\n      $parent.removeEventListener('blur', handleBlur)\n    }\n  }, [])\n\n  return (\n    <>\n      <div ref={ref} className=\"hidden\"></div>\n      <AnimatePresence>\n        {enter && (\n          <motion.div\n            className=\"absolute inset-y-4 -inset-x-4 -z-1 bg-accent/10 rounded-lg\"\n            initial={{ opacity: 0.2, scale: 0.95 }}\n            animate={{ opacity: 1, scale: 1 }}\n            exit={{ opacity: 0, scale: 0.95 }}\n            layout\n            layoutId=\"post-card-hover-overlay\"\n          ></motion.div>\n        )}\n      </AnimatePresence>\n    </>\n  )\n}\n"
  },
  {
    "path": "src/components/post/PostCopyright.tsx",
    "content": "import { author, site } from '@/config.json'\nimport { getFormattedDateTime } from '@/utils/date'\nimport { AnimatedSignature } from '../AnimatedSignature'\nimport { useEffect, useState } from 'react'\nimport { toast } from \"react-toastify\";\n\nfunction getPostUrl(slug: string) {\n  return new URL(slug, site.url).href\n}\n\nexport function PostCopyright({\n  title,\n  slug,\n  lastMod,\n}: {\n  title: string\n  slug: string\n  lastMod: Date\n}) {\n  const [lastModStr, setLastModStr] = useState('')\n  const url = getPostUrl(slug)\n\n  function handleCopyUrl() {\n    navigator.clipboard.writeText(url)\n    toast.success('已复制文章链接')\n  }\n\n  useEffect(() => {\n    setLastModStr(getFormattedDateTime(lastMod))\n  }, [lastMod])\n\n  return (\n    <section className=\"text-xs leading-loose text-secondary\">\n      <p>文章标题：{title}</p>\n      <p>文章作者：{author.name}</p>\n      <p>\n        <span>文章链接：{url}</span>\n        <span role=\"button\" className=\"cursor-pointer select-none\" onClick={handleCopyUrl}>\n          [复制]\n        </span>\n      </p>\n      <p>最后修改时间：{lastModStr}</p>\n      <hr className=\"my-3 border-primary\" />\n      <div>\n        <div className=\"float-right ml-4 my-2\">\n          <AnimatedSignature />\n        </div>\n        <p>\n          商业转载请联系站长获得授权，非商业转载请注明本文出处及文章链接，您可以自由地在任何媒体以任何形式复制和分发作品，也可以修改和创作，但是分发衍生作品时必须采用相同的许可协议。\n          <br />\n          本文采用\n          <a\n            className=\"hover:underline hover:text-accent underline-offset-2\"\n            href=\"https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh\"\n            target=\"_blank\"\n            rel=\"noopener noreferrer\"\n          >\n            CC BY-NC-SA 4.0\n          </a>\n          进行许可。\n        </p>\n      </div>\n    </section>\n  )\n}\n"
  },
  {
    "path": "src/components/post/PostList.astro",
    "content": "---\nimport type { CollectionEntry } from 'astro:content'\nimport PostCard from './PostCard.astro'\n\ninterface Props {\n  posts: CollectionEntry<'posts'>[]\n}\n\nconst { posts } = Astro.props\n---\n\n<div>\n  <ul class=\"-my-4\">\n    {\n      posts.map((post) => (\n        <li>\n          <PostCard entry={post} />\n        </li>\n      ))\n    }\n  </ul>\n</div>\n"
  },
  {
    "path": "src/components/post/PostMetaInfo.astro",
    "content": "---\nimport { RelativeDate } from './RelativeDate'\n\ninterface Props {\n  date: Date\n  lastMod?: Date\n  words: number\n  readingMinutes: number\n  class?: string\n}\n\nconst { date, lastMod, words, readingMinutes, class: className } = Astro.props\n---\n\n<div class=\"flex flex-wrap gap-2 text-sm text-secondary\" class:list={[className]}>\n  <div>\n    <i class=\"iconfont icon-calendar\"></i>\n    <RelativeDate date={date} client:idle />\n    {lastMod && <span class=\"text-xs\">(已编辑)</span>}\n  </div>\n  <div>\n    <i class=\"iconfont icon-file-list\"></i>\n    <span>{words} 字</span>\n  </div>\n  <div>\n    <i class=\"iconfont icon-timer\"></i>\n    <span>{Math.ceil(readingMinutes)} 分钟</span>\n  </div>\n</div>\n"
  },
  {
    "path": "src/components/post/PostNav.astro",
    "content": "---\nimport type { CollectionEntry } from 'astro:content'\n\ninterface Props {\n  prev?: CollectionEntry<'posts'>\n  next?: CollectionEntry<'posts'>\n  class?: string\n}\n\nconst { prev, next, class: className } = Astro.props\n---\n\n<div class=\"grid grid-cols-2\" class:list={[className]}>\n  <div>\n    {\n      prev && (\n        <a class=\"flex items-baseline gap-2 hover:text-accent\" href={`/posts/${prev.slug}`}>\n          <i class=\"iconfont icon-arrow-left\" />\n          <span>{prev.data.title}</span>\n        </a>\n      )\n    }\n  </div>\n  <div>\n    {\n      next && (\n        <a\n          class=\"flex items-baseline justify-end gap-2 hover:text-accent\"\n          href={`/posts/${next.slug}`}\n        >\n          <span>{next.data.title}</span>\n          <i class=\"iconfont icon-arrow-right\" />\n        </a>\n      )\n    }\n  </div>\n</div>\n"
  },
  {
    "path": "src/components/post/PostPagination.astro",
    "content": "---\ninterface Props {\n  current: number\n  total: number\n  getPageUrl: (page: number) => string\n}\n\nconst { current, total, getPageUrl } = Astro.props\n\nconst items = []\nif (current > 1) items.push({ isButton: true, page: current - 1, icon: 'left', label: '上一页' })\nif (current > 1) items.push({ isButton: true, page: 1 })\nif (current > 3) items.push({ isButton: false, icon: 'more' })\nif (current > 2) items.push({ isButton: true, page: current - 1 })\nitems.push({ isButton: false, page: current })\nif (current < total - 1) items.push({ isButton: true, page: current + 1 })\nif (current < total - 2) items.push({ isButton: false, icon: 'more' })\nif (current < total) items.push({ isButton: true, page: total })\nif (current < total)\n  items.push({ isButton: true, page: current + 1, icon: 'right', label: '下一页' })\n---\n\n<div class=\"mt-12 flex items-center justify-center gap-2\">\n  {\n    items.map((item) => {\n      if (item.isButton) {\n        return (\n          <a\n            class=\"size-8 rounded-lg flex items-center justify-center transition-bg-color duration-200  hover:bg-accent/20 select-none\"\n            href={getPageUrl(item.page!)}\n            aria-label={item.label}\n          >\n            {item.icon ? <i class={`iconfont icon-${item.icon}`} /> : item.page}\n          </a>\n        )\n      } else {\n        return (\n          <span\n            class=\"size-8 rounded-lg flex items-center justify-center cursor-default select-none\"\n            class:list={[{ 'text-white bg-accent dark:text-black': item.page === current }]}\n          >\n            {item.icon ? <i class={`iconfont icon-${item.icon}`} /> : item.page}\n          </span>\n        )\n      }\n    })\n  }\n</div>\n"
  },
  {
    "path": "src/components/post/PostToc.tsx",
    "content": "import { pageScrollLocationAtom, pageScrollDirectionAtom } from '@/store/scrollInfo'\nimport type { MarkdownHeading } from 'astro'\nimport clsx from 'clsx'\nimport { useAtomValue } from 'jotai'\nimport { startTransition, useEffect, useRef, useState } from 'react'\n\nfunction useActiveItem() {\n  const [activeItem, setActiveItem] = useState('')\n  const scrollY = useAtomValue(pageScrollLocationAtom)\n\n  useEffect(() => {\n    const $article = document.querySelector('#markdown-wrapper')\n    if (!$article) return\n    const $headings = Array.from($article.querySelectorAll('h1,h2,h3,h4,h5,h6'))\n    for (let i = 0; i < $headings.length; i++) {\n      const item = $headings[i]\n      const nextItem = $headings[i + 1]\n      const itemTop = item.getBoundingClientRect().top\n      const nextItemTop = nextItem ? nextItem.getBoundingClientRect().top : 10000\n\n      if (itemTop <= 80 && nextItemTop > 80) {\n        startTransition(() => {\n          setActiveItem(item.id)\n        })\n        break\n      }\n    }\n  }, [scrollY])\n\n  return activeItem\n}\n\nexport function PostToc({ headings }: { headings: MarkdownHeading[] }) {\n  const activeItem = useActiveItem()\n\n  return (\n    <ul\n      className=\"relative overflow-y-auto space-y-2 group text-sm\"\n      style={{\n        maxHeight: 'min(380px, calc(100vh - 250px))',\n        scrollbarWidth: 'none',\n      }}\n    >\n      {headings.map((item) => (\n        <TocItem\n          key={item.slug}\n          slug={item.slug}\n          text={item.text}\n          depth={item.depth}\n          isActive={item.slug === activeItem}\n        />\n      ))}\n    </ul>\n  )\n}\n\nexport function TocItem({\n  slug,\n  text,\n  depth,\n  isActive,\n}: {\n  slug: string\n  text: string\n  depth: number\n  isActive: boolean\n}) {\n  const itemRef = useRef<HTMLLIElement>(null)\n  const scrollDirection = useAtomValue(pageScrollDirectionAtom)\n\n  useEffect(() => {\n    if (!isActive) return\n    const $item = itemRef.current\n    if (!$item) return\n    const $container = $item.parentElement\n    if (!$container) return\n\n    const containerHeight = $container.clientHeight\n    const itemHeight = $item.clientHeight\n    const itemOffsetTop = $item.offsetTop\n    const scrollTop = $container.scrollTop\n\n    const itemTop = itemOffsetTop - scrollTop\n    const itemBottom = itemTop + itemHeight\n\n    if (itemTop < 0 || itemBottom > containerHeight) {\n      if (scrollDirection === 'up') {\n        $container.scrollTop = itemOffsetTop - containerHeight + itemHeight\n\n      } else {\n        $container.scrollTop = itemOffsetTop\n      }\n    }\n  }, [isActive])\n\n  return (\n    <li className=\"relative\" ref={itemRef}>\n      <span\n        className={clsx(\n          'absolute left-0 top-2 h-1 rounded-full',\n          isActive ? 'bg-accent' : 'bg-zinc-300 dark:bg-zinc-700',\n        )}\n        style={{ width: `${4 * (7 - depth)}px` }}\n      ></span>\n      <a\n        className={clsx(\n          'inline-block pl-8 opacity-0 transition-opacity duration-300',\n          isActive ? 'opacity-100' : 'group-hover:opacity-100 text-zinc-500 hover:text-zinc-900 dark:hover:text-zinc-100',\n        )}\n        href={`#${slug}`}\n      >\n        <span>{text}</span>\n      </a>\n    </li>\n  )\n}\n"
  },
  {
    "path": "src/components/post/ReadingProgress.tsx",
    "content": "import { useEffect, useState } from 'react'\nimport { useAtomValue } from 'jotai'\nimport { pageScrollLocationAtom } from '@/store/scrollInfo'\nimport { floor } from 'lodash-es'\n\nexport function ReadingProgress() {\n  const [percent, setPercent] = useState(0)\n  const scrollY = useAtomValue(pageScrollLocationAtom)\n\n  useEffect(() => {\n    const $article = document.querySelector('#markdown-wrapper')\n    if (!$article) return\n\n    const { offsetHeight, offsetTop } = $article as HTMLElement\n    const fullHeight = offsetHeight + offsetTop - window.innerHeight\n\n    if (scrollY > fullHeight) {\n      setPercent(100)\n    } else {\n      setPercent(floor((scrollY / fullHeight) * 100))\n    }\n  }, [scrollY])\n\n  return (\n    <div>\n      <span className=\"text-sm\">进度 {percent}%</span>\n    </div>\n  )\n}\n"
  },
  {
    "path": "src/components/post/RelativeDate.tsx",
    "content": "import { getRelativeTime, getFormattedDate } from '@/utils/date'\nimport { useEffect, useState } from 'react'\n\nexport function RelativeDate({ date }: { date: Date }) {\n  const [dateStr, setDateStr] = useState(getFormattedDate(date))\n\n  useEffect(() => {\n    const relative = getRelativeTime(date)\n    if (relative) {\n      setDateStr(relative)\n    }\n  }, [date])\n\n  return <span>{dateStr}</span>\n}\n"
  },
  {
    "path": "src/components/provider/HeaderMetaInfoProvider.tsx",
    "content": "import { useSetAtom } from 'jotai'\nimport { useEffect } from 'react'\nimport { pathNameAtom, metaTitleAtom, metaDescriptionAtom, metaSlugAtom } from '@/store/metaInfo'\n\nexport function HeaderMetaInfoProvider({\n  pathName,\n  title = '',\n  description = '',\n  slug = '',\n}: {\n  pathName: string\n  title?: string\n  description?: string\n  slug?: string\n}) {\n  const setPathName = useSetAtom(pathNameAtom)\n  const setTitle = useSetAtom(metaTitleAtom)\n  const setDescription = useSetAtom(metaDescriptionAtom)\n  const setSlug = useSetAtom(metaSlugAtom)\n\n  useEffect(() => {\n    // 去掉 pathName 结尾的 '/'\n    if (pathName !== '/') {\n      setPathName(pathName.replace(/\\/$/, ''))\n    } else {\n      setPathName(pathName)\n    }\n    setTitle(title)\n    setDescription(description)\n    setSlug(slug)\n  }, [pathName, title, description, slug])\n\n  return null\n}\n"
  },
  {
    "path": "src/components/provider/PageScrollInfoProvider.tsx",
    "content": "import { useLayoutEffect, useRef } from 'react'\nimport { throttle } from 'lodash-es'\nimport { useSetAtom } from 'jotai'\nimport { pageScrollLocationAtom, pageScrollDirectionAtom } from '@/store/scrollInfo'\n\nexport function PageScrollInfoProvider() {\n  const setScrollLocation = useSetAtom(pageScrollLocationAtom)\n  const setScrollDirection = useSetAtom(pageScrollDirectionAtom)\n  const prevScrollY = useRef(0)\n\n  const scrollHandler = throttle(\n    () => {\n      let currentTop = document.documentElement.scrollTop\n\n      if (currentTop === 0) {\n        const bodyStyle = document.body.style\n        if (bodyStyle.position === 'fixed') {\n          const bodyTop = bodyStyle.top\n          currentTop = Math.abs(parseInt(bodyTop, 10))\n        }\n      }\n\n      setScrollDirection(prevScrollY.current - currentTop > 0 ? 'up' : 'down')\n      prevScrollY.current = currentTop\n      setScrollLocation(currentTop)\n    },\n    16,\n    {\n      leading: false,\n    },\n  )\n\n  useLayoutEffect(() => {\n    scrollHandler()\n    window.addEventListener('scroll', scrollHandler)\n    return () => {\n      window.removeEventListener('scroll', scrollHandler)\n    }\n  }, [])\n  return null\n}\n"
  },
  {
    "path": "src/components/provider/Provider.tsx",
    "content": "import { HeaderMetaInfoProvider } from './HeaderMetaInfoProvider'\nimport { PageScrollInfoProvider } from './PageScrollInfoProvider'\nimport { ThemeProvider } from './ThemeProvider'\nimport { ViewportProvider } from './ViewportProvider'\n\nexport function Provider(props: {\n  pathName: string\n  title?: string\n  description?: string\n  slug?: string\n}) {\n  return (\n    <>\n      <HeaderMetaInfoProvider {...props} />\n      <PageScrollInfoProvider />\n      <ThemeProvider />\n      <ViewportProvider />\n    </>\n  )\n}\n"
  },
  {
    "path": "src/components/provider/ThemeProvider.tsx",
    "content": "import { useAtomValue } from 'jotai'\nimport { useEffect } from 'react'\nimport { getSystemTheme, changePageTheme, setLocalTheme } from '@/utils/theme'\nimport { themeAtom } from '@/store/theme'\n\nexport function ThemeProvider() {\n  const theme = useAtomValue(themeAtom)\n\n  function handlePrefersColorSchemeChange(event: MediaQueryListEvent) {\n    if (theme === 'system') {\n      changePageTheme(event.matches ? 'dark' : 'light')\n    }\n  }\n\n  useEffect(() => {\n    setLocalTheme(theme)\n\n    if (theme === 'system') {\n      const systemTheme = getSystemTheme()\n      changePageTheme(systemTheme)\n    } else {\n      changePageTheme(theme)\n    }\n\n    const query = window.matchMedia('(prefers-color-scheme: dark)')\n    query.addEventListener('change', handlePrefersColorSchemeChange)\n\n    return () => {\n      query.removeEventListener('change', handlePrefersColorSchemeChange)\n    }\n  }, [theme])\n\n  return null\n}\n"
  },
  {
    "path": "src/components/provider/ViewportProvider.tsx",
    "content": "import { useSetAtom } from 'jotai'\nimport { useEffect } from 'react'\nimport { isMobileAtom } from '@/store/viewport'\n\nexport function ViewportProvider() {\n  const setIsMobile = useSetAtom(isMobileAtom)\n\n  const handleResize = (event: MediaQueryListEvent) => {\n    setIsMobile(!event.matches)\n  }\n\n  useEffect(() => {\n    const query = window.matchMedia('(min-width: 768px)')\n    setIsMobile(!query.matches)\n    query.addEventListener('change', handleResize)\n    return () => {\n      query.removeEventListener('change', handleResize)\n    }\n  }, [])\n\n  return null\n}\n"
  },
  {
    "path": "src/components/ui/modal/Modal.tsx",
    "content": "import { modalStackAtom } from '@/store/modalStack'\nimport { useSetAtom } from 'jotai'\nimport * as Dialog from '@radix-ui/react-dialog'\nimport { motion } from 'framer-motion'\nimport { CurrentModalContext } from './context'\n\nexport function Modal({\n  children,\n  index,\n  id,\n}: {\n  index: number\n  children: React.ReactNode\n  id: string\n}) {\n  const baseZIndex = 1000\n  const overlayZIndex = baseZIndex + index\n  const contentZIndex = baseZIndex + index + 1\n  const setModalStack = useSetAtom(modalStackAtom)\n\n  const close = () => {\n    setModalStack((stack) => stack.filter((modal) => modal.id !== id))\n  }\n\n  return (\n    <Dialog.Root\n      open\n      onOpenChange={(isOpen) => {\n        if (!isOpen) {\n          close()\n        }\n      }}\n    >\n      <Dialog.Portal>\n        <Dialog.Overlay asChild>\n          <motion.div\n            className=\"fixed inset-0 bg-gray-800/40\"\n            style={{ zIndex: overlayZIndex }}\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0, transition: { delay: 0.1 } }}\n          ></motion.div>\n        </Dialog.Overlay>\n\n        <Dialog.Content\n          className=\"fixed inset-0 flex items-center justify-center\"\n          style={{ zIndex: contentZIndex }}\n          onClick={(e) => {\n            if (e.target === e.currentTarget) {\n              close()\n            }\n          }}\n        >\n          <CurrentModalContext.Provider value={{ dismiss: close }}>\n            {children}\n          </CurrentModalContext.Provider>\n        </Dialog.Content>\n      </Dialog.Portal>\n    </Dialog.Root>\n  )\n}\n"
  },
  {
    "path": "src/components/ui/modal/ModalStack.tsx",
    "content": "import { useAtomValue } from 'jotai'\nimport { Modal } from './Modal'\nimport { modalStackAtom } from '@/store/modalStack'\nimport { AnimatePresence } from 'framer-motion'\n\nexport function ModalStack() {\n  const modalStack = useAtomValue(modalStackAtom)\n\n  return (\n    <AnimatePresence>\n      {modalStack.map((modal, index) => (\n        <Modal key={modal.id} index={index} id={modal.id}>\n          {modal.content}\n        </Modal>\n      ))}\n    </AnimatePresence>\n  )\n}\n"
  },
  {
    "path": "src/components/ui/modal/context.ts",
    "content": "import { createContext } from 'react'\n\nexport const CurrentModalContext = createContext<{\n  dismiss: () => void\n}>(null as any)\n"
  },
  {
    "path": "src/components/ui/modal/hooks.ts",
    "content": "import { useContext, useId, useRef } from 'react'\nimport { useSetAtom } from 'jotai'\nimport { modalStackAtom } from '@/store/modalStack'\nimport { CurrentModalContext } from './context'\n\ntype ModalProps = {\n  id?: string\n  content: React.ReactNode\n}\n\nexport function useModal() {\n  const id = useId()\n  const currentCount = useRef(0)\n  const setModalStack = useSetAtom(modalStackAtom)\n\n  return {\n    present(props: ModalProps) {\n      const modalId = `${id}-${currentCount.current++}`\n      const modalProps = {\n        ...props,\n        id: props.id ?? modalId,\n      }\n      setModalStack((stack) => [...stack, modalProps])\n      return () => {\n        setModalStack((stack) => stack.filter((modal) => modal.id !== modalProps.id))\n      }\n    },\n  }\n}\n\nexport function useCurrentModal() {\n  return useContext(CurrentModalContext)\n}\n"
  },
  {
    "path": "src/components/ui/modal/index.ts",
    "content": "export * from './hooks'\nexport * from './ModalStack'\n"
  },
  {
    "path": "src/config.json",
    "content": "{\n  \"site\": {\n    \"url\": \"https://gyoza.lxchapu.com\",\n    \"title\": \"Gyoza\",\n    \"description\": \"这是一个使用 Astro 和 React 开发的博客主题。\",\n    \"keywords\": \"Gyoza,blog,Astro,theme,lxchapu,博客主题\",\n    \"lang\": \"zh-CN\",\n    \"favicon\": \"/favicon.ico\",\n    \"appleTouchIcon\": \"/apple-touch-icon.png\"\n  },\n  \"author\": {\n    \"name\": \"lxchapu\",\n    \"twitterId\": \"@lxchapu\",\n    \"avatar\": \"https://s2.loli.net/2024/04/30/ozsnuS5Ihf3xMBG.webp\"\n  },\n  \"hero\": {\n    \"name\": \"Gyoza\",\n    \"bio\": \"A static blog template build with Astro and React.\",\n    \"description\": \"Clean, Cute, Fast.\",\n    \"socials\": [\n      {\n        \"name\": \"Github\",\n        \"icon\": \"icon-github\",\n        \"url\": \"https://github.com/lxchapu/astro-gyoza\",\n        \"color\": \"rgb(24, 23, 23)\"\n      },\n      {\n        \"name\": \"X\",\n        \"icon\": \"icon-x\",\n        \"url\": \"https://twitter.com/lxchapu\",\n        \"color\": \"rgb(36, 46, 54)\"\n      },\n      {\n        \"name\": \"Email\",\n        \"icon\": \"icon-mail\",\n        \"url\": \"mailto:lxchapu@outlook.com\",\n        \"color\": \"rgb(212, 70, 56)\"\n      }\n    ],\n    \"yiyan\": \"当第一颗卫星飞向大气层外，我们便以为自己终有一日会征服宇宙。\"\n  },\n  \"color\": {\n    \"accent\": [\n      { \"light\": \"#F55555\", \"dark\": \"#FCCF31\" },\n      { \"light\": \"#0396FF\", \"dark\": \"#ABDCFF\" },\n      { \"light\": \"#fb7287\", \"dark\": \"#99D8CF\" },\n      { \"light\": \"#F072B6\", \"dark\": \"#FFF886\" },\n      { \"light\": \"#9F44D3\", \"dark\": \"#E2B0FF\" },\n      { \"light\": \"#FF6666\", \"dark\": \"#A1CCD1\" },\n      { \"light\": \"#F6416C\", \"dark\": \"#838BC6\" },\n      { \"light\": \"#32CCBC\", \"dark\": \"#90F7EC\" },\n      { \"light\": \"#33A6B8\", \"dark\": \"#79F1A4\" },\n      { \"light\": \"#F55555\", \"dark\": \"#FCCF31\" }\n    ],\n    \"bg\": {\n      \"primary\": { \"light\": \"#ffffff\", \"dark\": \"#1c1c1e\" },\n      \"secondary\": { \"light\": \"#f4f4f5\", \"dark\": \"#27272a\" }\n    },\n    \"text\": {\n      \"primary\": { \"light\": \"#373a3c\", \"dark\": \"#ffffff\" },\n      \"secondary\": { \"light\": \"#71717a\", \"dark\": \"#d1d5db\" }\n    },\n    \"border\": {\n      \"primary\": { \"light\": \"#e4e4e7\", \"dark\": \"#3f3f46\" }\n    }\n  },\n  \"menus\": [\n    {\n      \"name\": \"首页\",\n      \"link\": \"/\",\n      \"icon\": \"icon-pantone\"\n    },\n    {\n      \"name\": \"归档\",\n      \"link\": \"/archives\",\n      \"icon\": \"icon-archive\"\n    },\n    {\n      \"name\": \"项目\",\n      \"link\": \"/projects\",\n      \"icon\": \"icon-flask\"\n    },\n    {\n      \"name\": \"关于\",\n      \"link\": \"/about\",\n      \"icon\": \"icon-ghost\"\n    },\n    {\n      \"name\": \"友链\",\n      \"link\": \"/friends\",\n      \"icon\": \"icon-hearts\"\n    }\n  ],\n  \"posts\": {\n    \"perPage\": 10\n  },\n  \"footer\": {\n    \"startTime\": \"2024-04-14T00:00:00Z\"\n  },\n  \"waline\": {\n    \"serverURL\": \"https://waline.lxchapu.com\"\n  },\n  \"sponsor\": {\n    \"wechat\": \"https://object.lxchapu.com/bed%2F2024%2F0507_6e3e8f73df2d4e6d.webp\"\n  },\n  \"analytics\": {\n    \"enable\": false,\n    \"google\": {\n      \"measurementId\": \"\"\n    },\n    \"umami\": {\n      \"serverUrl\": \"\",\n      \"websiteId\": \"\"\n    },\n    \"microsoftClarity\": {\n      \"projectId\": \"\"\n    }\n  }\n}\n"
  },
  {
    "path": "src/content/config.ts",
    "content": "import { z, defineCollection } from 'astro:content'\n\nconst postsCollection = defineCollection({\n  type: 'content',\n  schema: z.object({\n    title: z.string(),\n    date: z.date(),\n    lastMod: z.date().optional(),\n    summary: z.string().optional(),\n    cover: z.string().optional(),\n    category: z.string().optional(),\n    tags: z.array(z.string()).default([]),\n    comments: z.boolean().default(true),\n    draft: z.boolean().default(false),\n    sticky: z.number().default(0),\n  }),\n})\n\nconst projectsCollection = defineCollection({\n  type: 'data',\n  schema: z.object({\n    title: z.string(),\n    description: z.string(),\n    image: z.string(),\n    link: z.string().url(),\n  }),\n})\n\nconst specCollection = defineCollection({\n  type: 'content',\n  schema: z.object({\n    title: z.string(),\n    description: z.string(),\n    comments: z.boolean().default(true),\n  }),\n})\n\nconst friendsCollection = defineCollection({\n  type: 'data',\n  schema: z.object({\n    title: z.string(),\n    description: z.string(),\n    avatar: z.string(),\n    link: z.string().url(),\n  }),\n})\n\nexport const collections = {\n  posts: postsCollection,\n  projects: projectsCollection,\n  spec: specCollection,\n  friends: friendsCollection,\n}\n"
  },
  {
    "path": "src/content/friends/Keigo.yml",
    "content": "title: Keigo\ndescription: 那天早上的霧散了,不止早上,不止霧\nlink: https://astro.sliverkeigo.top/\navatar: https://www.sliverkeigo.top/_next/image?url=https%3A%2F%2Fsliverkeigo.top%2Fapi%2Fv2%2Fobjects%2Favatar%2Fd7mox619mtisq9vtxt.png&w=384&q=75\n"
  },
  {
    "path": "src/content/friends/astro-docs.yaml",
    "content": "title: Astro Docs\ndescription: Astro 入门指南\nlink: https://docs.astro.build/en/getting-started/\navatar: https://s2.loli.net/2023/12/13/YbKirkO21CtdvMD.png\n"
  },
  {
    "path": "src/content/friends/lxchapu.yaml",
    "content": "title: '柃夏chapu'\ndescription: '生活明朗，万物可爱。'\nlink: 'https://www.lxchapu.com'\navatar: 'https://s2.loli.net/2024/04/23/tIxXmT45RbBDWH8.webp'\n"
  },
  {
    "path": "src/content/posts/embed.md",
    "content": "---\ntitle: 在文章中嵌入视频和代码\ndate: 2024-04-04\nlastMod: 2024-05-18T07:29:49.820Z\ntags: [Video, Markdown]\ncategory: 例子\nsummary: 这篇文章介绍了如何在文章中嵌入视频和代码。\n---\n\n## Codepen\n\n```md\n::codepen{#gOyLepE author=\"lxchapu\"}\n```\n\n::codepen{#gOyLepE author=\"lxchapu\"}\n\n## YouTube\n\n```md\n::youtube{#BuKft9LpL_0}\n```\n\n::youtube{#BuKft9LpL_0}\n\n## Bilibili\n\n```md\n::bilibili{#BV1Mx4y1Y7pJ}\n```\n\n::bilibili{#BV1Mx4y1Y7pJ}\n"
  },
  {
    "path": "src/content/posts/guide.md",
    "content": "---\ntitle: Gyoza 使用指南\ndate: 2024-04-01\nlastMod: 2024-08-10T03:58:16.758Z\nsummary: 欢迎使用 Gyoza，Gyoza 是一款 Astro 博客主题，它保持简洁和可爱的风格。本篇文章将会介绍如何使用并部署 Gyoza。\ncategory: 教程\ntags: [Astro, Gyoza]\nsticky: 1\n---\n\n## 前置条件\n\n- node 版本 >= 18.18.0\n- pnpm 版本 > 8.1.0\n\n## 安装\n\n### 克隆仓库\n\n登录 Github 账号，打开 [lxchapu/astro-gyoza](https://github.com/lxchapu/astro-gyoza)，点击右上角的 Fork 按钮，将仓库克隆到你自己的账号下。\n\n复制这个仓库的地址，打开终端，使用 `git clone` 命令将仓库克隆到本地。\n\n> 本项目推荐使用 pnpm 作为你的包管理器，如果你还没有安装 pnpm，请先安装 pnpm。\n\n### 安装依赖\n\n```sh\ncd astro-gyoza\npnpm install\n```\n\n### 命令介绍\n\n本地运行\n\n```sh\npnpm dev\n```\n\n打包静态文件\n\n```sh\npnpm build\n```\n\n本地预览\n\n```sh\npnpm preview\n```\n\n### 配置项\n\n本项目中的绝大部分配置都定义在 `src/config.json` 文件中。\n\n你应该首先将 `site.url` 修改成自己的域名，避免导航错误。\n\n以下是配置项的说明：\n\n```json\n{\n  \"site\": {\n    \"url\": \"\", // 网站地址\n    \"title\": \"\", // 网站标题\n    \"description\": \"\", // 通用的网站描述 SEO\n    \"keywords\": \"\", // 通用的网站关键词 SEO\n    \"lang\": \"zh-CN\", // 网站的语言\n    \"favicon\": \"\", // 浏览器图标，存放在 public 目录下\n    \"appleTouchIcon\": \"\" // 苹果设备图标，存放在 public 目录下\n  },\n  \"author\": {\n    \"name\": \"\", // 作者名称\n    \"twitterId\": \"\", // 推特账号 ID，以 @ 开头，用于 Open Graph\n    \"avatar\": \"\" // 作者头像地址\n  },\n  // 首页 Hero 组件\n  \"hero\": {\n    \"name\": \"\", // 显示的名称\n    \"bio\": \"\", // 一句话介绍\n    \"description\": \"\", // 补充描述\n    // 社交账号\n    \"socials\": [\n      {\n        \"name\": \"\", // 社交平台类型\n        \"icon\": \"\", // 社交平台图标\n        \"url\": \"\", // 链接\n        \"color\": \"\" // 图标颜色\n      }\n    ],\n    \"yiyan\": \"\" // 显示一言\n  },\n  \"color\": {\n    // 强调色，请填写 16 进制颜色值。每次会从中随机取出一组\n    \"accent\": [{ \"light\": \"\", \"dark\": \"\" }],\n    // 背景色\n    \"bg\": {\n      \"primary\": { \"light\": \"\", \"dark\": \"\" },\n      \"secondary\": { \"light\": \"\", \"dark\": \"\" }\n    },\n    // 文字颜色\n    \"text\": {\n      \"primary\": { \"light\": \"\", \"dark\": \"\" },\n      \"secondary\": { \"light\": \"\", \"dark\": \"\" }\n    },\n    // 边框颜色\n    \"border\": {\n      \"primary\": { \"light\": \"\", \"dark\": \"\" }\n    }\n  },\n  // 顶部导航栏\n  \"menus\": [\n    {\n      \"name\": \"首页\",\n      \"link\": \"/\",\n      \"icon\": \"icon-pantone\"\n    }\n  ],\n  \"posts\": {\n    \"perPage\": 10 // 每一页显示的文章数量\n  },\n  \"footer\": {\n    \"startTime\": \"\" // 博客网站开始时间 请使用 ISO 格式\n  },\n  // Waline 评论系统，前往 https://waline.js.org/ 查看\n  \"waline\": {\n    \"serverURL\": \"\"\n  },\n  // 赞助\n  \"sponsor\": {\n    \"wechat\": \"\" // 微信赞赏码图片地址\n  },\n  // 如果需要使用网站数据统计，将 enable 修改为 true，并填写对应的配置\n  \"analytics\": {\n    \"enable\": false,\n    // https://analytics.google.com\n    \"google\": {\n      \"measurementId\": \"\"\n    },\n    // https://umami.is/docs\n    \"umami\": {\n      \"serverUrl\": \"\",\n      \"websiteId\": \"\"\n    },\n    // https://clarity.microsoft.com/\n    \"microsoftClarity\": {\n      \"projectId\": \"\"\n    }\n  }\n}\n```\n\n## 部署\n\n> 这里只介绍了 Vercel，你当然可以选择其他平台例如：Cloudflare Pages 或你自己的服务器。  \n> 部署之前，确保你已经修改 `site.url`。\n\n### 部署到 Vercel\n\n登录 Vercel 账号，点击右上角的 Add new... 选择 Project。然后在 Import Git Repository 中选择刚刚 Fork 的仓库，点击 Import 按钮。\n\n进入项目配置页面，直接点击 Deploy 按钮，静静等待部署完成就 👌 了。\n\nVercel 会为你分配一个域名，你可以在项目设置中设置自定义域名，更多操作请参考 Vercel 文档。\n"
  },
  {
    "path": "src/content/posts/how-to-use-icons.md",
    "content": "---\ntitle: 如何在 Gyoza 中使用图标？\ndate: 2024-05-08T10:54:27.000Z\ntags: [Icon]\ncategory: 教程\ncomments: true\ndraft: false\n---\n\nGyoza 选择 font-class 的方式引用图标。这些图标大部分来源于 [Remix Icons](https://remixicon.com/)，并且在 [iconfont](https://www.iconfont.cn/) 上进行管理和导出。\n\n下图展示了项目中的所有图标：\n\n![所有图标](https://s2.loli.net/2024/05/08/mbdT5HqYMEajyRG.webp)\n\n当你在添加首页显示的社交账号时，你可能会想要使用这些图标。在对应的配置项中填写图标下面有 `icon-` 前缀的名称即可。\n\n如果是在组件中使用图标，可以按照如下方式：\n\n```jsx\n<i className=\"iconfont icon-xxx\"></i>\n```\n\n## 为什么不是 SVG 图标？\n\n你可能看到很多的项目在使用 [iconify](https://iconify.design/)。iconify 是一个开源图标集，包含超过 20 万个图标，提供了多种框架的引入方式。Astro 中也有对应的插件 astro-icon 可以使用（如果对此感兴趣，可以查看他们的[文档](https://github.com/natemoo-re/astro-icon)）。\n\n我在项目中也尝试使用过 iconify，但是出于以下几个原因，我最终还是转向了 font-class 的方式：\n\n- 由于项目中同时使用了 Astro 和 React，而在 Astro 组件和 React 组件中使用 iconify 图标的方式是不同的，这会导致代码中不得不存在两种使用方式。\n- iconify 在加载时需要请求它的服务器，~~我会担心请求失败~~，虽然这种担心是多余的。\n- 有一个功能是我会在渲染文章时往 markdown 中注入一些图标，例如外部链接尾部的图标，iconify 想要做到这一点并不方便。\n- 在 HTML 中直接嵌入 SVG icon 的方式并不优雅，使用 font-class 只需要对应的类名，感觉相较而言最终的 HTML 体积小一点，页面加载会快点。我还没有做过具体的测试，但是至少我会尽量避免页面中出现大量的 SVG 仅仅只是作为图标使用。\n- 该项目中用到的图标并不多，主要是一些常用的社交账号的图标，供自定义联系方式时使用。我希望所有图标集中在一起管理，这样更方便一点。\n\n我必须要承认，目前的图标方案并不优雅，每当图标集合发生修改时我都需要更新对应的字体文件和 CSS 文件。而且其他人想要管理图标集合也变得困难。\n\n也许我会在未来尝试其他方式，例如 [@iconify/tailwind](https://github.com/iconify/iconify/tree/main/plugins/tailwind)，如果你有更好的方案，也欢迎给我留言。\n\n## 自定义图标\n\n如果你想要替换 iconfont 的图标，请修改以下文件：\n\n```text\npublic/fonts/iconfont.ttf\npublic/fonts/iconfont.woff\npublic/fonts/iconfont.woff2\nsrc/styles/iconfont.css\n```\n\n注意，这将会替换掉项目中使用的所有图标，所以请确保你知道自己在做什么。\n"
  },
  {
    "path": "src/content/posts/markdown.md",
    "content": "---\ntitle: Markdown 示例\ndate: 2024-04-01\nsummary: 这是一篇 Markdown 文章的示例。展示了 Markdown 的语法和渲染效果。\ncategory: 例子\ntags: [Markdown]\n---\n\n下面是在 Astro 中编写 Markdown 内容时，可以使用的一些基本 Markdown 语法示例。\n\n## 标题\n\n你应该避免在 Markdown 正文中重复创建文章标题，因为文章标题会根据 `frontmatter` 中 `title` 自动生成。\n\n> 避免标题层级过深，一般到三级标题就够了。\n\n# 一级\n\n## 二级\n\n### 三级 `inline code`\n\n#### 四级\n\n##### 五级\n\n###### 六级\n\n## 段落\n\nXerum, quo qui aut unt expliquam qui dolut labo. Aque venitatiusda cum, voluptionse latur sitiae dolessi aut parist aut dollo enim qui voluptate ma dolestendit peritin re plis aut quas inctum laceat est volestemque commosa as cus endigna tectur, offic to cor sequas etum rerum idem sintibus eiur? Quianimin porecus evelectur, cum que nis nust voloribus ratem aut omnimi, sitatur? Quiatem. Nam, omnis sum am facea corem alique molestrunt et eos evelece arcillit ut aut eos eos nus, sin conecerem erum fuga. Ri oditatquam, ad quibus unda veliamenimin cusam et facea ipsamus es exerum sitate dolores editium rerore eost, temped molorro ratiae volorro te reribus dolorer sperchicium faceata tiustia prat.\n\n使用行尾使用两个空格进行段落内的换行\n\nAll work and no play makes Jack a dull boy.  \nAll work and no play makes Jack a dull boy.\n\n## 图片\n\n小尺寸的图片\n\n![图片描述](https://picsum.photos/seed/picsum/250/400)\n\n大尺寸的图片\n\n![图片描述](https://picsum.photos/seed/picsum/1200/900)\n\n带标题的图片\n\n![图片描述](https://picsum.photos/seed/picsum/400/300 '图片标题')\n\n## 强调\n\n这是**重要内容**，这是*次要内容*\n\n## 删除线\n\n~~这是一段被删除的文本。~~\n\n## 引用\n\nThe blockquote element represents content that is quoted from another source, optionally with a citation which must be within a `footer` or `cite` element, and optionally with in-line changes such as annotations and abbreviations.\n\n> Tiam, ad mint andaepu dandae nostion secatur sequo quae.  \n> **Note** that you can use _Markdown syntax_ within a blockquote.\n\n嵌套的引用\n\n> 引用\n>\n> > 嵌套的引用\n\n带脚标的引用\n\n> Don't communicate by sharing memory, share memory by communicating.<br>\n> — <cite>Rob Pike[^1]</cite>\n\n[^1]: The above quote is excerpted from Rob Pike's [talk](https://www.youtube.com/watch?v=PAAkCSZUG1c) during Gopherfest, November 18, 2015.\n\n## 分割线\n\n---\n\n## 链接\n\n这是内部链接 [Gyoza 使用指南](/posts/guide)\n\n这是外部连接 [React **中文**文档](https://zh-hans.react.dev/)\n\n自动渲染成连接 <https://github.com>\n\n邮箱地址 <mail@example.com>\n\n## 表格\n\n设置单元格对齐\n\n| Name  | Age |  Fruit |\n| :---- | :-: | -----: |\n| Bob   | 27  |  Apple |\n| Alice | 23  | Banana |\n| John  | 28  | Orange |\n\n支持行内 Markdown\n\n| Italics   | Bold     | Code   |\n| --------- | -------- | ------ |\n| _italics_ | **bold** | `code` |\n\n表格溢出\n\n| A                                                        | B                                                                                                             | C                                                                                                                                    | D                                                 | E                                                          | F                                                                    |\n| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------- | ---------------------------------------------------------- | -------------------------------------------------------------------- |\n| Lorem ipsum dolor sit amet, consectetur adipiscing elit. | Phasellus ultricies, sapien non euismod aliquam, dui ligula tincidunt odio, at accumsan nulla sapien eget ex. | Proin eleifend dictum ipsum, non euismod ipsum pulvinar et. Vivamus sollicitudin, quam in pulvinar aliquam, metus elit pretium purus | Proin sit amet velit nec enim imperdiet vehicula. | Ut bibendum vestibulum quam, eu egestas turpis gravida nec | Sed scelerisque nec turpis vel viverra. Vivamus vitae pretium sapien |\n\n## 代码块\n\n### Syntax\n\nwe can use 3 backticks ``` in new line and write snippet and close with 3 backticks on new line and to highlight language specific syntac, write one word of language name after first 3 backticks, for eg. html, javascript, css, markdown, typescript, txt, bash\n\n```html\n<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\" />\n    <title>Example HTML5 Document</title>\n  </head>\n  <body>\n    <p>Test</p>\n  </body>\n</html>\n```\n\n```\nconst var text = \"hello world\"\n```\n\n## KaTeX 公式\n\n使用 `$` 符号包裹公式生成行内公式，例如：$E = mc^2$。\n\n使用 `$$` 符号包裹公式来生成独立公式。例如：\n\n$$\ne^{i\\pi} + 1 = 0\n$$\n\n也可以使用代码块（` ```math `）的方式：\n\n```math\n\\oint_{\\partial V} \\mathbf{E} \\cdot d\\mathbf{A} = \\frac{Q}{\\epsilon_0}\n```\n\n## List Types\n\n### Ordered List\n\n#### Syntax\n\n```markdown\n1. First item\n2. Second item\n3. Third item\n```\n\n#### Output\n\n1. First item\n2. Second item\n3. Third item\n\n### Unordered List\n\n#### Syntax\n\n```markdown\n- List item\n- Another item\n- And another item\n```\n\n#### Output\n\n- List item\n- Another item\n- And another item\n\n### Nested list\n\n#### Syntax\n\n```markdown\n- Fruit\n  - Apple\n  - Orange\n  - Banana\n- Dairy\n  - Milk\n  - Cheese\n```\n\n#### Output\n\n- Fruit\n  - Apple\n  - Orange\n  - Banana\n- Dairy\n  - Milk\n  - Cheese\n\n## Other Elements — abbr, sub, sup, kbd, mark\n\n### Syntax\n\n```markdown\n<abbr title=\"Graphics Interchange Format\">GIF</abbr> is a bitmap image format.\n\nH<sub>2</sub>O\n\nX<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>\n\nPress <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>Delete</kbd></kbd> to end the session.\n\nMost <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.\n```\n\n#### Output\n\n<abbr title=\"Graphics Interchange Format\">GIF</abbr> is a bitmap image format.\n\nH<sub>2</sub>O\n\nX<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>\n\nPress <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>Delete</kbd></kbd> to end the session.\n\nMost <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.\n\n## Spoiler\n\n```md\n||hide content||\n```\n\n正常情况下，该内容会隐藏 ||hide content||，鼠标悬浮时才会显示。\n"
  },
  {
    "path": "src/content/projects/gyoza.yaml",
    "content": "title: Gyoza\ndescription: Gyoza 是一个使用 Astro 和 React 开发的响应式博客主题\nimage: https://s2.loli.net/2024/03/02/hba5MAilRXguZtr.webp\nlink: https://github.com/lxchapu/astro-gyoza\n"
  },
  {
    "path": "src/content/spec/about.md",
    "content": "---\ntitle: 自述\ndescription: 这是一份站长的自述报告，请查收。\ncomments: false\n---\n\n## 关于 Gyoza\n\nGyoza 是一个使用 Astro 和 React 开发的博客主题。Gyoza 借鉴了 [Shiro](https://github.com/innei/Shiro) 和一些网站的设计。\n\nGyoza 的核心理念是简洁，快速，可爱。\n\n- 在 [Markdown 示例](/posts/markdown) 中展示了 Markdown 的渲染样式\n- 可以前往 [Gyoza 使用指南](/posts/guide) 了解 Gyoza 的使用方法\n\nGyoza 是开源的，如果你对这个项目感兴趣，欢迎前往 Gyoza 的 [Github 仓库](https://github.com/lxchapu/astro-gyoza) 来提 Issue 或者 PR。\n\n## 关于作者\n\n我是 lxchapu，是一名前端开发者，喜欢各种有趣的东西。欢迎访问我的个人网站 [www.lxchapu.com](https://www.lxchapu.com)，了解关于我更多的信息。\n\n## 致谢\n\n感谢以下项目：\n\n- [Astro](https://astro.build/)\n- [React](https://reactjs.org/)\n- [Tailwind CSS](https://tailwindcss.com/)\n- [Framer Motion](https://www.framer.com/motion/)\n- [Jotai](https://jotai.org/)\n"
  },
  {
    "path": "src/content/spec/friends.md",
    "content": "---\ntitle: 朋友们\ndescription: 我的小伙伴们和一些有趣的站点。\ncomments: true\n---\n\n## 怎么申请友链？\n\n想要交换友链的小伙伴们，欢迎去本站的 [Github 仓库](https://github.com/lxchapu/astro-gyoza/tree/main/src/content/friends)提交一个 PR。审核通过后，就可以在这里展示啦。\n\n请在`/src/content/friends/`目录下添加一个`<short-name>.yaml`文件，参考格式：\n\n```yml\ntitle: 网站名称\ndescription: 一句话介绍下你的网站或者你自己\nlink: 网站地址\navatar: 头像地址\n```\n"
  },
  {
    "path": "src/content/spec/projects.md",
    "content": "---\ntitle: 项目\ndescription: 这些是我创建或参与的项目，如果你感兴趣不妨去给个 Star。\ncomments: false\n---\n"
  },
  {
    "path": "src/env.d.ts",
    "content": "/// <reference path=\"../.astro/types.d.ts\" />\n/// <reference types=\"astro/client\" />\n"
  },
  {
    "path": "src/hooks/useDebounceValue.ts",
    "content": "import { useEffect, useState } from 'react'\n\nexport function useDebounceValue<T>(value: T, delay: number) {\n  const [debouncedValue, setDebouncedValue] = useState(value)\n\n  useEffect(() => {\n    const handler = setTimeout(() => {\n      setDebouncedValue(value)\n    }, delay)\n\n    return () => {\n      clearTimeout(handler)\n    }\n  }, [value, delay])\n\n  return debouncedValue\n}\n"
  },
  {
    "path": "src/layouts/Layout.astro",
    "content": "---\nimport {\n  CommonHead,\n  WebAnalytics,\n  ThemeLoader,\n  AccentColorInjector,\n  PrintVersion,\n} from '@/components/head'\nimport { BackToTopFAB } from '@/components/BackToTopFAB'\nimport { ToastContainer } from '@/components/ToastContainer'\nimport { ModalStack } from '@/components/ui/modal'\nimport { site } from '@/config.json'\nimport '@/styles/global.css'\n\ninterface Props {\n  title?: string\n  description?: string\n  image?: string\n}\n\nconst { title, description, image } = Astro.props\n---\n\n<!doctype html>\n<html lang={site.lang}>\n  <head>\n    <CommonHead title={title} description={description} image={image} />\n    <WebAnalytics />\n    <ThemeLoader />\n    <AccentColorInjector />\n    <PrintVersion />\n  </head>\n  <body>\n    <slot />\n\n    <BackToTopFAB client:only=\"react\" />\n    <ToastContainer client:only=\"react\" />\n    <ModalStack client:only=\"react\" />\n  </body>\n</html>\n"
  },
  {
    "path": "src/layouts/MarkdownLayout.astro",
    "content": "---\nimport Layout from './Layout.astro'\nimport { HeadGradient } from '@/components/head-gradient'\nimport Footer from '@/components/footer/Footer.astro'\nimport { Header } from '@/components/header/Header'\nimport { Provider } from '@/components/provider/Provider'\nimport 'katex/dist/katex.min.css'\n\ninterface Props {\n  title: string\n  description?: string\n  image?: string\n  mdTitle: string\n  mdDescription: string\n  mdSlug: string\n}\n\nconst { title, description, image, mdTitle, mdDescription, mdSlug } = Astro.props\n---\n\n<Layout title={title} description={description} image={image}>\n  <Provider\n    pathName={Astro.url.pathname}\n    title={mdTitle}\n    description={mdDescription}\n    slug={mdSlug}\n    client:only=\"react\"\n  />\n\n  <Header client:only=\"react\" />\n  <main class=\"relative z-1 pt-16 min-h-main bg-primary\">\n    <HeadGradient client:idle />\n    <div class=\"swup-transition-fade\">\n      <slot />\n    </div>\n  </main>\n  <Footer />\n</Layout>\n"
  },
  {
    "path": "src/layouts/PageLayout.astro",
    "content": "---\nimport Layout from './Layout.astro'\nimport { Header } from '@/components/header/Header'\nimport Footer from '@/components/footer/Footer.astro'\nimport { Provider } from '@/components/provider/Provider'\n\ninterface Props {\n  title?: string\n  description?: string\n  image?: string\n}\n\nconst { title, description, image } = Astro.props\n---\n\n<Layout title={title} description={description} image={image}>\n  <Provider pathName={Astro.url.pathname} client:only=\"react\" />\n\n  <Header client:only=\"react\" />\n  <main class=\"relative z-1 pt-16 min-h-main bg-primary\">\n    <div class=\"swup-transition-fade\">\n      <slot />\n    </div>\n  </main>\n  <Footer />\n</Layout>\n"
  },
  {
    "path": "src/pages/404.astro",
    "content": "---\nimport Layout from '@/layouts/Layout.astro'\nimport { Flashlight } from '@/components/Flashlight'\n---\n\n<Layout title=\"404\">\n  <div class=\"max-w-[800px] mx-auto py-16 px-4 md:px-8\">\n    <h1 class=\"text-[4rem] md:text-[9rem] leading-tight font-bold\">Not Found</h1>\n    <p class=\"text-3xl mb-24 text-gray-800/90 dark:text-gray-200/90\">\n      对不起，这个链接坏了。可能有些东西被删除，或者被移动了。无论如何，这里没什么可看的。\n    </p>\n    <a class=\"text-accent text-xl md:text-2xl inline-flex\" href=\"/\"\n      ><i class=\"iconfont icon-arrow-left-up\"></i>\n      <span class=\"ml-2\">传送回首页</span></a\n    >\n  </div>\n  <Flashlight client:only=\"react\" />\n</Layout>\n"
  },
  {
    "path": "src/pages/[...page].astro",
    "content": "---\nimport type { GetStaticPaths } from 'astro'\nimport PageLayout from '@/layouts/PageLayout.astro'\nimport PostList from '@/components/post/PostList.astro'\nimport PostPagination from '@/components/post/PostPagination.astro'\nimport { getSortedPosts, getHotTags, getAllCategories, getAllTags } from '@/utils/content'\nimport appConfig from '@/config.json'\nimport SectionBlock from '@/components/SectionBlock.astro'\nimport TagList from '@/components/TagList.astro'\nimport CategoryList from '@/components/CategoryList.astro'\nimport type { CollectionEntry } from 'astro:content'\nimport Hero from '@/components/hero/Hero.astro'\n\nexport const getStaticPaths = (async () => {\n  const sortedPosts = await getSortedPosts()\n  const { perPage } = appConfig.posts\n  const totalPage = Math.ceil(sortedPosts.length / perPage)\n\n  const paths = Array.from({ length: totalPage }).map((_, i) => {\n    const data = sortedPosts.slice(i * perPage, (i + 1) * perPage)\n    const props = { currentPage: i + 1, totalPage, data }\n    const params = {\n      page: i === 0 ? undefined : `page/${i + 1}`,\n    }\n    return { params, props }\n  })\n\n  return paths\n}) satisfies GetStaticPaths\n\ninterface Props {\n  currentPage: number\n  totalPage: number\n  data: CollectionEntry<'posts'>[]\n}\n\nconst { currentPage, totalPage, data } = Astro.props\n\nconst hotTags = await getHotTags()\nconst allTags = await getAllTags()\nconst allCategories = await getAllCategories()\n\nconst getPageUrl = (page: number) => {\n  if (page === 1) return '/'\n  return `/page/${page}`\n}\n---\n\n<PageLayout>\n  <div>\n    {currentPage === 1 && <Hero />}\n    <div class=\"max-w-[1100px] px-4 md:px-8 py-20 mx-auto grid lg:grid-cols-[auto_300px] gap-10\">\n      <div class=\"min-w-0\">\n        <SectionBlock title=\"最新发布\">\n          <PostList posts={data} />\n          {\n            totalPage > 1 && (\n              <PostPagination current={currentPage} total={totalPage} getPageUrl={getPageUrl} />\n            )\n          }\n        </SectionBlock>\n      </div>\n      <div>\n        <aside class=\"md:sticky md:top-20 space-y-10\">\n          <SectionBlock title=\"分类\">\n            <CategoryList categories={allCategories} />\n          </SectionBlock>\n          <SectionBlock title=\"热门标签\">\n            <TagList tags={hotTags} />\n            {\n              allTags.length > hotTags.length && (\n                <div class=\"mt-2 text-right\">\n                  <a class=\"text-sm text-secondary hover:text-accent\" href=\"/tags\">\n                    更多标签 <i class=\"iconfont icon-arrow-right\" />\n                  </a>\n                </div>\n              )\n            }\n          </SectionBlock>\n        </aside>\n      </div>\n    </div>\n  </div>\n</PageLayout>\n"
  },
  {
    "path": "src/pages/[spec].astro",
    "content": "---\nimport type { GetStaticPaths } from 'astro'\nimport type { CollectionEntry } from 'astro:content'\nimport { getCollection } from 'astro:content'\nimport MarkdownLayout from '@/layouts/MarkdownLayout.astro'\nimport PageLayout from '@/layouts/PageLayout.astro'\nimport Highlight from '@/components/Highlight.astro'\nimport SectionBlock from '@/components/SectionBlock.astro'\nimport MarkdownWrapper from '@/components/MarkdownWrapper.astro'\nimport FriendList from '@/components/FriendList.astro'\nimport ProjectList from '@/components/ProjectList.astro'\nimport { ReadingProgress } from '@/components/post/ReadingProgress'\nimport { PostToc } from '@/components/post/PostToc'\nimport { Comments } from '@/components/comment'\n\nexport const getStaticPaths = (async () => {\n  const specList = await getCollection('spec')\n\n  return specList.map((md) => ({\n    params: { spec: md.slug },\n    props: {\n      md,\n    },\n  }))\n}) satisfies GetStaticPaths\n\ninterface Props {\n  md: CollectionEntry<'spec'>\n}\n\nconst { md } = Astro.props\n\nconst { headings, Content } = await md.render()\n\nconst isPageLayout = ['friends', 'projects'].includes(md.slug)\nconst isMdContentEmpty = md.body.trim().length === 0\n---\n\n{\n  isPageLayout ? (\n    <PageLayout title={md.data.title} description={md.data.description}>\n      <div class=\"max-w-[800px] mx-auto px-4 py-16 space-y-8\" data-pagefind-body>\n        <header class=\"space-y-4\">\n          <h1 class=\"text-4xl font-bold\">\n            <Highlight>{md.data.title}</Highlight>\n          </h1>\n          <p>{md.data.description}</p>\n        </header>\n        {md.slug === 'friends' && <FriendList />}\n        {md.slug === 'projects' && <ProjectList />}\n        {!isMdContentEmpty && (\n          <MarkdownWrapper>\n            <Content />\n          </MarkdownWrapper>\n        )}\n        {md.data.comments && <Comments />}\n      </div>\n    </PageLayout>\n  ) : (\n    <MarkdownLayout\n      title={md.data.title}\n      description={md.data.description}\n      mdTitle={md.data.title}\n      mdDescription={md.data.description}\n      mdSlug={md.slug}\n    >\n      <div\n        class=\"max-w-[1100px] mx-auto px-4 md:px-8 py-16 grid lg:grid-cols-[auto_260px] gap-8\"\n        data-pagefind-body\n      >\n        <div>\n          <header class=\"space-y-4\">\n            <h1 class=\"text-4xl font-bold\">\n              <Highlight>{md.data.title}</Highlight>\n            </h1>\n            <p>{md.data.description}</p>\n          </header>\n        </div>\n        <div class=\"col-start-1 min-w-0\">\n          <MarkdownWrapper>\n            <Content />\n          </MarkdownWrapper>\n        </div>\n        <div class=\"hidden lg:block\" data-pagefind-ignore>\n          <aside class=\"sticky top-20\">\n            <SectionBlock title=\"目录\">\n              <PostToc headings={headings} client:idle />\n              <hr class=\"my-2 border-primary max-w-[100px]\" />\n              <ReadingProgress client:idle />\n            </SectionBlock>\n          </aside>\n        </div>\n        {md.data.comments && <Comments />}\n      </div>\n    </MarkdownLayout>\n  )\n}\n"
  },
  {
    "path": "src/pages/archives.astro",
    "content": "---\nimport Timeline from '@/components/Timeline.astro'\nimport Highlight from '@/components/Highlight.astro'\nimport PageLayout from '@/layouts/PageLayout.astro'\nimport { getOldestPosts } from '@/utils/content'\nimport { TimelineProgress } from '@/components/TimelineProgress'\n\nconst oldestPosts = await getOldestPosts()\n---\n\n<PageLayout title=\"归档\">\n  <div class=\"max-w-[800px] mx-auto px-4 py-16\">\n    <header class=\"space-y-4 mb-8\">\n      <h1 class=\"text-4xl font-bold\">\n        <Highlight>归档</Highlight>\n      </h1>\n      <p>共产出 {oldestPosts.length} 篇文章，再接再厉。</p>\n      <hr class=\"w-[100px] border-primary\" />\n      <TimelineProgress client:load />\n    </header>\n    <Timeline posts={oldestPosts} />\n  </div>\n</PageLayout>\n"
  },
  {
    "path": "src/pages/categories/[category].astro",
    "content": "---\nimport type { GetStaticPaths } from 'astro'\nimport PageLayout from '@/layouts/PageLayout.astro'\nimport { getAllCategories, getOldestPosts, slugify } from '@/utils/content'\nimport Highlight from '@/components/Highlight.astro'\nimport Timeline from '@/components/Timeline.astro'\n\nexport const getStaticPaths = (async () => {\n  const allCategories = await getAllCategories()\n\n  return allCategories.map((category) => {\n    return {\n      params: {\n        category: category.slug,\n      },\n      props: { category },\n    }\n  })\n}) satisfies GetStaticPaths\n\ninterface Props {\n  category: {\n    name: string\n    slug: string\n    count: number\n  }\n}\n\nconst { category } = Astro.props\n\nconst oldestPosts = await getOldestPosts().then((posts) => {\n  return posts.filter((post) => post.data.category && slugify(post.data.category) === category.slug)\n})\n---\n\n<PageLayout title={`分类 · ${category.name}`}>\n  <div class=\"max-w-[800px] mx-auto px-4 py-16\">\n    <header class=\"space-y-4 mb-8\">\n      <h1 class=\"text-4xl font-bold\">\n        分类：<Highlight>{category.name}</Highlight>\n      </h1>\n      <p>共有 {category.count} 篇文章。</p>\n    </header>\n    <Timeline posts={oldestPosts} />\n  </div>\n</PageLayout>\n"
  },
  {
    "path": "src/pages/posts/[...slug].astro",
    "content": "---\nimport type { CollectionEntry } from 'astro:content'\nimport type { GetStaticPaths } from 'astro'\nimport MarkdownLayout from '@/layouts/MarkdownLayout.astro'\nimport { getSortedPosts } from '@/utils/content'\nimport MarkdownWrapper from '@/components/MarkdownWrapper.astro'\nimport SectionBlock from '@/components/SectionBlock.astro'\nimport { PostToc } from '@/components/post/PostToc'\nimport PostMetaInfo from '@/components/post/PostMetaInfo.astro'\nimport PostArchiveInfo from '@/components/post/PostArchiveInfo.astro'\nimport { ReadingProgress } from '@/components/post/ReadingProgress'\nimport { Outdate } from '@/components/post/Outdate'\nimport PostNav from '@/components/post/PostNav.astro'\nimport { Comments } from '@/components/comment'\nimport { ActionAside } from '@/components/post/ActionAside'\nimport { PostCopyright } from '@/components/post/PostCopyright'\n\nexport const getStaticPaths = (async () => {\n  const sortedPosts = await getSortedPosts()\n\n  return sortedPosts.map((post, index) => ({\n    params: { slug: post.slug },\n    props: {\n      current: post,\n      prev: index > 0 ? sortedPosts[index - 1] : undefined,\n      next: index < sortedPosts.length - 1 ? sortedPosts[index + 1] : undefined,\n    },\n  }))\n}) satisfies GetStaticPaths\n\ninterface Props {\n  current: CollectionEntry<'posts'>\n  prev?: CollectionEntry<'posts'>\n  next?: CollectionEntry<'posts'>\n}\n\nconst { current, prev, next } = Astro.props\n\nconst { headings, Content, remarkPluginFrontmatter } = await current.render()\n\nconst mdSlug = `/posts/${current.slug}`\n\nconst mdDescription = concat(current.data.category || '', current.data.tags.join(', '))\n\nfunction concat(str1: string, str2: string, sep = ' / ') {\n  if (str1 && str2) return str1 + sep + str2\n  if (str1) return str1\n  if (str2) return str2\n  return ''\n}\n\nconst lastMod = current.data.lastMod || current.data.date\n---\n\n<MarkdownLayout\n  title={current.data.title}\n  description={current.data.summary}\n  image={current.data.cover}\n  mdTitle={current.data.title}\n  mdDescription={mdDescription}\n  mdSlug={mdSlug}\n>\n  <div\n    class=\"max-w-[1100px] mx-auto px-4 md:px-8 py-16 grid lg:grid-cols-[auto_260px] gap-8\"\n    data-pagefind-body\n  >\n    <div>\n      <header class=\"space-y-4\">\n        <h1 class=\"text-4xl font-bold text-center\">\n          {current.data.title}\n        </h1>\n        <PostMetaInfo\n          class=\"justify-center\"\n          date={current.data.date}\n          lastMod={current.data.lastMod}\n          words={remarkPluginFrontmatter.words}\n          readingMinutes={remarkPluginFrontmatter.readingMinutes}\n        />\n        <PostArchiveInfo\n          class=\"justify-center\"\n          category={current.data.category}\n          tags={current.data.tags}\n        />\n        <div>\n          <Outdate lastMod={lastMod} client:idle />\n        </div>\n      </header>\n    </div>\n    <div class=\"col-start-1 min-w-0\">\n      <MarkdownWrapper>\n        <Content />\n      </MarkdownWrapper>\n    </div>\n    <div class=\"hidden lg:block\" data-pagefind-ignore>\n      <aside class=\"sticky top-20\">\n        <SectionBlock title=\"目录\">\n          <PostToc headings={headings} client:idle />\n          <hr class=\"my-2 border-primary max-w-[100px]\" />\n          <ReadingProgress client:idle />\n        </SectionBlock>\n        <ActionAside client:idle />\n      </aside>\n    </div>\n    <div data-pagefind-ignore>\n      <section class=\"space-y-6\">\n        <PostCopyright title={current.data.title} slug={mdSlug} lastMod={lastMod} client:visible />\n        <PostNav prev={prev} next={next} />\n        {current.data.comments && <Comments />}\n      </section>\n    </div>\n  </div>\n</MarkdownLayout>\n"
  },
  {
    "path": "src/pages/robots.txt.ts",
    "content": "import type { APIRoute } from 'astro'\n\nconst robotsTxt = `\nUser-agent: *\nAllow: /\n\nDisallow: /_astro/\nDisallow: /fonts/\n\nSitemap: ${new URL('sitemap-index.xml', import.meta.env.SITE).href}\n`.trim()\n\nexport const GET: APIRoute = () => {\n  return new Response(robotsTxt, {\n    headers: {\n      'Content-Type': 'text/plain; charset=utf-8',\n    },\n  })\n}\n"
  },
  {
    "path": "src/pages/rss.xml.ts",
    "content": "import type { APIContext } from 'astro'\nimport rss from '@astrojs/rss'\nimport { site } from '@/config.json'\nimport { getSortedPosts } from '@/utils/content'\n\nexport async function GET(context: APIContext) {\n  const sortedPosts = await getSortedPosts()\n\n  return rss({\n    title: site.title,\n    description: site.description,\n    site: context.site!,\n    items: sortedPosts.map((post) => ({\n      link: `/posts/${post.slug}`,\n      title: post.data.title,\n      pubDate: post.data.date,\n      description: post.data.summary,\n    })),\n    customData: `<language>${site.lang}</language>`,\n  })\n}\n"
  },
  {
    "path": "src/pages/tags/[tag].astro",
    "content": "---\nimport type { GetStaticPaths } from 'astro'\nimport { getAllTags, getOldestPosts, slugify } from '@/utils/content'\nimport PageLayout from '@/layouts/PageLayout.astro'\nimport Timeline from '@/components/Timeline.astro'\nimport Highlight from '@/components/Highlight.astro'\n\nexport const getStaticPaths = (async () => {\n  const allTags = await getAllTags()\n\n  return allTags.map((tag) => {\n    return {\n      params: {\n        tag: tag.slug,\n      },\n      props: { tag },\n    }\n  })\n}) satisfies GetStaticPaths\n\ninterface Props {\n  tag: {\n    name: string\n    slug: string\n    count: number\n  }\n}\n\nconst { tag } = Astro.props\n\nconst oldestPosts = await getOldestPosts().then((posts) => {\n  return posts.filter((post) => post.data.tags.findIndex((t) => slugify(t) === tag.slug) >= 0)\n})\n---\n\n<PageLayout title={`标签 · ${tag.name}`}>\n  <div class=\"max-w-[800px] mx-auto px-4 py-16\">\n    <header class=\"space-y-4 mb-8\">\n      <h1 class=\"text-4xl font-bold\">\n        标签：<Highlight>{tag.name}</Highlight>\n      </h1>\n      <p>共有 {tag.count} 篇文章。</p>\n    </header>\n    <Timeline posts={oldestPosts} />\n  </div>\n</PageLayout>\n"
  },
  {
    "path": "src/pages/tags/index.astro",
    "content": "---\nimport TagList from '@/components/TagList.astro'\nimport Highlight from '@/components/Highlight.astro'\nimport { getAllTags } from '@/utils/content'\nimport PageLayout from '@/layouts/PageLayout.astro'\n\nconst allTags = await getAllTags()\n---\n\n<PageLayout title=\"标签\">\n  <div class=\"max-w-[800px] mx-auto px-4 py-16\">\n    <header class=\"space-y-4 mb-8\">\n      <h1 class=\"text-4xl font-bold\">\n        <Highlight>标签云</Highlight>\n      </h1>\n      <p>共有 {allTags.length} 个标签。</p>\n    </header>\n\n    <TagList tags={allTags} />\n  </div>\n</PageLayout>\n"
  },
  {
    "path": "src/plugins/rehypeCodeBlock.js",
    "content": "import { h } from 'hastscript'\nimport { visit } from 'unist-util-visit'\n\nexport function rehypeCodeBlock() {\n  return function (tree) {\n    visit(tree, { tagName: 'pre' }, (node, index, parent) => {\n      const child = node.children[0]\n      if (!child || child.type !== 'element' || child.tagName !== 'code' || !child.properties) {\n        return\n      }\n      const classes = child.properties.className\n      let lang = ''\n      if (!classes) {\n        node.children[0].properties = {\n          className: ['language-text'],\n        }\n        lang = 'text'\n      } else {\n        lang = classes[0].slice(9)\n      }\n\n      const codeBlock = h(\n        'div',\n        {\n          class: 'code-block',\n        },\n        [h('span', { class: 'lang-tag' }, lang), node],\n      )\n\n      parent.children[index] = codeBlock\n    })\n  }\n}\n"
  },
  {
    "path": "src/plugins/rehypeCodeHighlight.js",
    "content": "import rehypeShiki from '@shikijs/rehype'\n\nexport const rehypeCodeHighlight = [\n  rehypeShiki,\n  {\n    themes: {\n      light: 'github-light',\n      dark: 'github-dark',\n    },\n    defaultColor: false,\n  },\n]\n"
  },
  {
    "path": "src/plugins/rehypeHeading.js",
    "content": "import { h } from 'hastscript'\nimport { visit } from 'unist-util-visit'\n\nexport function rehypeHeading() {\n  return (tree) => {\n    visit(tree, 'element', (node, index, parent) => {\n      if (\n        node.tagName === 'h1' ||\n        node.tagName === 'h2' ||\n        node.tagName === 'h3' ||\n        node.tagName === 'h4' ||\n        node.tagName === 'h5' ||\n        node.tagName === 'h6'\n      ) {\n        const link = h(\n          'a',\n          {\n            href: `#${node.properties.id}`,\n            class: 'heading-anchor',\n            ariaLabel: 'Heading Anchor',\n          },\n          h('i', { class: 'iconfont icon-link' }),\n        )\n        node.children.push(link)\n        node.properties = {\n          ...node.properties,\n          class: 'heading',\n        }\n        parent.children[index] = node\n      }\n    })\n  }\n}\n"
  },
  {
    "path": "src/plugins/rehypeImage.js",
    "content": "import { h } from 'hastscript'\nimport { visit } from 'unist-util-visit'\n\nexport function rehypeImage() {\n  return function (tree) {\n    visit(tree, 'element', (node, index, parent) => {\n      if (node.tagName === 'p' && node.children.length === 1) {\n        const child = node.children[0]\n        if (child.tagName === 'img') {\n          parent.children[index] = buildFigure(child)\n        }\n      } else if (node.tagName === 'img') {\n        parent.children[index] = buildImage(node)\n      }\n    })\n  }\n}\n\nfunction buildImage(node) {\n  const imgProps = node.properties\n\n  return h('img', { ...imgProps, loading: 'lazy' })\n}\n\nfunction buildFigure(node) {\n  let imgTitle = node.properties.title\n  if (imgTitle) {\n    imgTitle = imgTitle.trim()\n  }\n\n  return h('figure', null, [buildImage(node), imgTitle ? h('figcaption', imgTitle) : null])\n}\n"
  },
  {
    "path": "src/plugins/rehypeLink.js",
    "content": "import { h } from 'hastscript'\nimport { visit } from 'unist-util-visit'\n\nexport function rehypeLink() {\n  return (tree) => {\n    visit(tree, { tagName: 'a' }, (node, index, parent) => {\n      const isExternal = node.properties.href.startsWith('http')\n      if (isExternal) {\n        node.properties = {\n          ...node.properties,\n          rel: 'noopener noreferrer',\n          target: '_blank',\n        }\n        parent.children[index] = node\n        const icon = h('i', { class: 'iconfont icon-external-link' })\n        parent.children.splice(index + 1, 0, icon)\n      }\n    })\n  }\n}\n"
  },
  {
    "path": "src/plugins/rehypeTableBlock.js",
    "content": "import { h } from 'hastscript'\nimport { visit } from 'unist-util-visit'\n\nexport function rehypeTableBlock() {\n  return function (tree) {\n    visit(tree, 'element', (node, index, parent) => {\n      if (node.tagName === 'table') {\n        const wrapper = h('div', { class: 'table-wrapper' }, [node])\n        parent.children[index] = wrapper\n      }\n      if (node.tagName === 'th' || node.tagName === 'td') {\n        const align = node.properties.align\n        if (align) {\n          node.properties.style = `text-align: ${align};`\n          delete node.properties.align\n        }\n      }\n    })\n  }\n}\n"
  },
  {
    "path": "src/plugins/remarkEmbed.js",
    "content": "import { visit } from 'unist-util-visit'\n\nexport function remarkEmbed() {\n  return function (tree) {\n    visit(tree, (node) => {\n      if (node.type === 'leafDirective') {\n        if (!['youtube', 'bilibili', 'codepen'].includes(node.name)) return\n\n        const data = node.data || (node.data = {})\n        const attributes = node.attributes || {}\n        const id = attributes.id\n\n        if (!id) return\n\n        data.hName = 'iframe'\n        switch (node.name) {\n          case 'youtube':\n            data.hProperties = {\n              class: 'video',\n              title: 'YouTube Video Player',\n              src: `https://www.youtube.com/embed/${id}`,\n              frameBorder: 0,\n              allow:\n                'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share',\n              allowFullScreen: true,\n              loading: 'lazy',\n            }\n            break\n          case 'bilibili':\n            data.hProperties = {\n              class: 'video',\n              title: 'Bilibili Video Player',\n              src: `//player.bilibili.com/player.html?isOutside=true&bvid=${id}`,\n              frameBorder: 0,\n              allowFullScreen: true,\n              loading: 'lazy',\n            }\n            break\n          case 'codepen':\n            data.hProperties = {\n              class: 'codepen',\n              title: 'CodePen Embed',\n              src: `https://codepen.io/${attributes.author}/embed/${id}`,\n              frameBorder: 0,\n              allowFullScreen: true,\n              loading: 'lazy',\n            }\n            break\n        }\n      }\n    })\n  }\n}\n"
  },
  {
    "path": "src/plugins/remarkReadingTime.js",
    "content": "import getReadingTime from 'reading-time'\nimport { toString } from 'mdast-util-to-string'\n\nexport function remarkReadingTime() {\n  return function (tree, { data }) {\n    const textOnPage = toString(tree)\n    const readingTime = getReadingTime(textOnPage)\n    data.astro.frontmatter.readingMinutes = readingTime.minutes\n    data.astro.frontmatter.words = readingTime.words\n  }\n}\n"
  },
  {
    "path": "src/plugins/remarkSpoiler.js",
    "content": "import { codes, types, constants } from 'micromark-util-symbol'\n\nexport function remarkSpoiler() {\n  const self = this\n  const data = self.data()\n\n  const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = [])\n  const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = [])\n\n  micromarkExtensions.push(spoilerSyntax())\n  fromMarkdownExtensions.push(spoilerFromMarkdown())\n}\n\nfunction spoilerSyntax() {\n  return {\n    text: {\n      [codes.verticalBar]: spoilerConstruct,\n    },\n  }\n}\n\nconst spoilerConstruct = { name: 'spoiler', tokenize: spoilerTokenize }\nconst markerConstruct = { tokenize: markerTokenize, partial: true }\n\nfunction spoilerTokenize(effects, ok, nok) {\n  function start() {\n    effects.enter('spoiler')\n    return effects.attempt(markerConstruct, contentStart, nok)\n  }\n\n  function contentStart() {\n    effects.enter(types.chunkText, {\n      contentType: constants.contentTypeText,\n    })\n    return content\n  }\n\n  function content() {\n    return effects.check(markerConstruct, contentEnd, consumeData)\n  }\n\n  function consumeData(code) {\n    if (code === codes.eof || code < codes.horizontalTab) {\n      return nok\n    }\n    effects.consume(code)\n    return content\n  }\n\n  function contentEnd() {\n    effects.exit(types.chunkText)\n    return effects.attempt(markerConstruct, after, nok)\n  }\n\n  function after() {\n    effects.exit('spoiler')\n    return ok\n  }\n\n  return start\n}\n\nfunction markerTokenize(effects, ok, nok) {\n  const previous = this.previous\n  let markSize = 0\n\n  function start() {\n    if (previous === codes.verticalBar) {\n      return nok\n    }\n    effects.enter('spoilerMarker')\n    return marker\n  }\n\n  function marker(code) {\n    if (code === codes.verticalBar) {\n      if (markSize > 1) {\n        return nok\n      }\n      effects.consume(code)\n      markSize++\n      return marker\n    }\n    if (markSize < 2) {\n      return nok\n    }\n    effects.exit('spoilerMarker')\n    return ok\n  }\n\n  return start\n}\n\nfunction spoilerFromMarkdown() {\n  function enterHandler(token) {\n    this.enter(\n      {\n        type: 'spoiler',\n        children: [],\n      },\n      token,\n    )\n  }\n\n  function exitHandler(token) {\n    const node = this.stack[this.stack.length - 1]\n    this.exit(token)\n    node.data = {\n      ...node.data,\n      hName: 'span',\n      hProperties: {\n        className: 'spoiler',\n        title: '你知道的太多了',\n      },\n    }\n  }\n\n  return {\n    enter: {\n      spoiler: enterHandler,\n    },\n    exit: {\n      spoiler: exitHandler,\n    },\n  }\n}\n"
  },
  {
    "path": "src/store/metaInfo.ts",
    "content": "import { atom } from 'jotai'\n\nexport const pathNameAtom = atom('')\nexport const metaTitleAtom = atom('')\nexport const metaDescriptionAtom = atom('')\nexport const metaSlugAtom = atom('')\n\nexport const hasMetaInfoAtom = atom((get) => {\n  const title = get(metaTitleAtom)\n  const description = get(metaDescriptionAtom)\n  const slug = get(metaSlugAtom)\n  return title !== '' && description !== '' && slug !== ''\n})\n"
  },
  {
    "path": "src/store/modalStack.ts",
    "content": "import { atom } from 'jotai'\n\nexport const modalStackAtom = atom<\n  {\n    id: string\n    content: React.ReactNode\n  }[]\n>([])\n"
  },
  {
    "path": "src/store/scrollInfo.ts",
    "content": "import { atom } from 'jotai'\n\nexport const pageScrollLocationAtom = atom(0)\nexport const pageScrollDirectionAtom = atom<'up' | 'down' | null>(null)\n"
  },
  {
    "path": "src/store/theme.ts",
    "content": "import { getLocalTheme } from '@/utils/theme'\nimport { atom } from 'jotai'\n\nexport const themeAtom = atom(getLocalTheme())\n"
  },
  {
    "path": "src/store/viewport.ts",
    "content": "import { atom } from 'jotai'\n\nexport const isMobileAtom = atom(false)\n"
  },
  {
    "path": "src/styles/global.css",
    "content": "@import './iconfont.css';\n@import './shiki.css';\n@import './markdown.css';\n@import './signature.css';\n@import './swup.css';\n\n@font-face {\n  font-family: 'Atkinson';\n  src: url('/fonts/atkinson-regular.woff') format('woff');\n  font-weight: 400;\n  font-style: normal;\n  font-display: swap;\n}\n\n@font-face {\n  font-family: 'Atkinson';\n  src: url('/fonts/atkinson-bold.woff') format('woff');\n  font-weight: 700;\n  font-style: normal;\n  font-display: swap;\n}\n\n::selection {\n  background-color: theme('colors.accent');\n  color: white;\n}\n\n[data-theme='dark'] ::selection {\n  background-color: theme('colors.accent/0.3');\n}\n\nhtml {\n  color: theme('textColor.primary');\n  background-color: theme('backgroundColor.root');\n  scroll-padding-top: 64px;\n}\n\nhtml.gray {\n  filter: grayscale(1);\n}\n\n* {\n  scrollbar-width: thin;\n}\n"
  },
  {
    "path": "src/styles/iconfont.css",
    "content": "@font-face {\n  font-family: 'iconfont';\n  /* Project id 4528205 */\n  src:\n    url('/fonts/iconfont.woff2?t=1716210197380') format('woff2'),\n    url('/fonts/iconfont.woff?t=1716210197380') format('woff'),\n    url('/fonts/iconfont.ttf?t=1716210197380') format('truetype');\n}\n\n.iconfont {\n  font-family: 'iconfont';\n  font-style: normal;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n}\n\n.icon-alert:before {\n  content: '\\e83a';\n}\n\n.icon-check:before {\n  content: '\\e847';\n}\n\n.icon-error:before {\n  content: '\\e854';\n}\n\n.icon-info:before {\n  content: '\\e85f';\n}\n\n.icon-close:before {\n  content: '\\e84a';\n}\n\n.icon-user-heart:before {\n  content: '\\e88c';\n}\n\n.icon-wechat:before {\n  content: '\\e7e3';\n}\n\n.icon-codepen:before {\n  content: '\\e7cd';\n}\n\n.icon-instagram:before {\n  content: '\\e7d3';\n}\n\n.icon-playstation:before {\n  content: '\\e7d9';\n}\n\n.icon-qq:before {\n  content: '\\e7da';\n}\n\n.icon-steam:before {\n  content: '\\e7e2';\n}\n\n.icon-switch:before {\n  content: '\\e7e5';\n}\n\n.icon-telegram:before {\n  content: '\\e7e6';\n}\n\n.icon-twitch:before {\n  content: '\\e7e7';\n}\n\n.icon-weibo:before {\n  content: '\\e7e8';\n}\n\n.icon-xbox:before {\n  content: '\\e7e9';\n}\n\n.icon-github:before {\n  content: '\\e7d2';\n}\n\n.icon-down:before {\n  content: '\\e83d';\n}\n\n.icon-map:before {\n  content: '\\e7fa';\n}\n\n.icon-more:before {\n  content: '\\e877';\n}\n\n.icon-left:before {\n  content: '\\e844';\n}\n\n.icon-right:before {\n  content: '\\e845';\n}\n\n.icon-rss:before {\n  content: '\\e74b';\n}\n\n.icon-ghost:before {\n  content: '\\e882';\n}\n\n.icon-contacts-book:before {\n  content: '\\e760';\n}\n\n.icon-x:before {\n  content: '\\eced';\n}\n\n.icon-pen:before {\n  content: '\\e720';\n}\n\n.icon-t-box:before {\n  content: '\\e727';\n}\n\n.icon-hearts:before {\n  content: '\\e7c1';\n}\n\n.icon-text:before {\n  content: '\\e7a8';\n}\n\n.icon-netease-cloud-music:before {\n  content: '\\e7d7';\n}\n\n.icon-pushpin:before {\n  content: '\\e7f1';\n}\n\n.icon-arrow-left-up:before {\n  content: '\\e842';\n}\n\n.icon-computer:before {\n  content: '\\e73a';\n}\n\n.icon-file-list:before {\n  content: '\\e76d';\n}\n\n.icon-link:before {\n  content: '\\e79b';\n}\n\n.icon-flask:before {\n  content: '\\e7bd';\n}\n\n.icon-douban:before {\n  content: '\\e7cc';\n}\n\n.icon-folder:before {\n  content: '\\e784';\n}\n\n.icon-hashtag:before {\n  content: '\\e798';\n}\n\n.icon-archive:before {\n  content: '\\e6be';\n}\n\n.icon-calendar:before {\n  content: '\\e6c9';\n}\n\n.icon-mail:before {\n  content: '\\e6da';\n}\n\n.icon-pantone:before {\n  content: '\\e71d';\n}\n\n.icon-quotes-l:before {\n  content: '\\e793';\n}\n\n.icon-quotes-r:before {\n  content: '\\e794';\n}\n\n.icon-heart:before {\n  content: '\\e7bf';\n}\n\n.icon-bilibili:before {\n  content: '\\e7c8';\n}\n\n.icon-zhihu:before {\n  content: '\\e7e4';\n}\n\n.icon-rocket:before {\n  content: '\\e7f3';\n}\n\n.icon-arrow-left:before {\n  content: '\\e841';\n}\n\n.icon-arrow-right:before {\n  content: '\\e843';\n}\n\n.icon-external-link:before {\n  content: '\\e853';\n}\n\n.icon-loader:before {\n  content: '\\e85d';\n}\n\n.icon-menu:before {\n  content: '\\e864';\n}\n\n.icon-search:before {\n  content: '\\e86e';\n}\n\n.icon-share:before {\n  content: '\\e874';\n}\n\n.icon-timer:before {\n  content: '\\e87c';\n}\n\n.icon-moon:before {\n  content: '\\e89c';\n}\n\n.icon-sun:before {\n  content: '\\e89e';\n}\n"
  },
  {
    "path": "src/styles/markdown.css",
    "content": ".markdown > :first-child {\n  @apply mt-0;\n}\n\n.markdown > :last-child {\n  @apply mb-0;\n}\n\n.markdown p {\n  @apply mb-5;\n}\n\n.markdown h1 {\n  @apply text-4xl font-extrabold mb-8;\n}\n\n.markdown h2 {\n  @apply text-2xl font-bold mt-12 mb-6;\n}\n\n.markdown h3 {\n  @apply text-xl font-semibold mt-8 mb-3;\n}\n\n.markdown h4 {\n  @apply font-semibold mt-6 mb-2;\n}\n\n.markdown a {\n  @apply font-normal text-accent hover:underline underline-offset-2;\n}\n\n.markdown a + .icon-external-link {\n  @apply text-secondary ml-1;\n}\n\n.markdown blockquote {\n  @apply my-5 pl-4 border-l-2 border-accent/80 text-secondary italic;\n}\n\n.markdown blockquote::before {\n  content: '\\e793';\n  font-family: 'iconfont';\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n  @apply not-italic text-accent/80;\n}\n\n.markdown blockquote > p:last-child {\n  @apply mb-0;\n}\n\n.markdown :not(pre) > code {\n  @apply px-2 py-1 rounded bg-secondary text-sm font-semibold;\n}\n\n.markdown .code-block {\n  @apply relative mt-10 mb-5 bg-secondary rounded-lg;\n}\n\n.markdown .lang-tag {\n  @apply absolute right-6 -top-6 h-6 px-4 flex items-center rounded-t-lg bg-inherit text-sm;\n}\n\n.markdown pre {\n  @apply px-6 py-4 max-h-[450px] text-sm leading-relaxed overflow-auto;\n}\n\n.markdown .table-wrapper {\n  @apply overflow-x-auto my-5;\n}\n\n.markdown table {\n  @apply w-auto mx-auto text-left table-auto text-sm;\n}\n\n.markdown tr {\n  @apply border-b border-primary;\n}\n\n.markdown th,\n.markdown td {\n  @apply p-2;\n}\n\n.markdown td {\n  @apply align-baseline;\n}\n\n.markdown img {\n  @apply rounded-lg bg-secondary min-h-[80px] min-w-[80px];\n}\n\n.markdown figure {\n  @apply mb-5 flex flex-col items-center;\n}\n\n.markdown figcaption {\n  @apply mt-3 text-secondary text-sm;\n}\n\n.markdown .heading-anchor {\n  @apply ml-1 opacity-0 hover:no-underline;\n}\n\n.markdown .heading:hover .heading-anchor,\n.markdown .heading-anchor:focus-visible {\n  @apply opacity-100;\n}\n\n.markdown iframe {\n  @apply rounded-lg w-full bg-secondary;\n}\n\n.markdown iframe.codepen {\n  @apply min-h-[450px];\n}\n\n.markdown iframe.video {\n  @apply aspect-video;\n}\n\n.markdown hr {\n  @apply my-12 mx-auto max-w-[100px] border-primary;\n}\n\n.markdown ul {\n  @apply list-disc;\n}\n\n.markdown ol {\n  @apply list-decimal;\n}\n\n.markdown ol,\n.markdown ul {\n  @apply my-5 pl-6 space-y-2;\n}\n\n.markdown ul ul,\n.markdown ul ol,\n.markdown ol ul,\n.markdown ol ol {\n  @apply my-3;\n}\n\n.markdown .spoiler {\n  @apply bg-current rounded transition-bg-color not-italic;\n}\n\n.markdown .spoiler:hover {\n  @apply bg-transparent;\n}\n\n.markdown h2 + * {\n  @apply mt-0;\n}\n\n.markdown h3 + * {\n  @apply mt-0;\n}\n\n.markdown h4 + * {\n  @apply mt-0;\n}\n"
  },
  {
    "path": "src/styles/shiki.css",
    "content": ".shiki,\n.shiki span {\n  color: var(--shiki-light);\n}\n\n[data-theme='dark'] .shiki,\n[data-theme='dark'] .shiki span {\n  color: var(--shiki-dark);\n}\n"
  },
  {
    "path": "src/styles/signature.css",
    "content": ".animated-signature path {\n  stroke-dasharray: 2400;\n  stroke-dashoffset: 2400;\n  fill: transparent;\n  animation: drawSignature 8s linear infinite both;\n  stroke-width: 2px;\n  stroke: theme('textColor.primary');\n}\n\n@keyframes drawSignature {\n  0% {\n    stroke-dashoffset: 2400;\n  }\n\n  15% {\n    fill: transparent;\n  }\n\n  35%,\n  75% {\n    stroke-dashoffset: 0;\n    fill: theme('textColor.primary');\n  }\n\n  90%,\n  to {\n    stroke-dashoffset: 2400;\n    fill: transparent;\n  }\n}\n"
  },
  {
    "path": "src/styles/swup.css",
    "content": "html.is-changing .swup-transition-fade {\n  transition: 0.4s;\n  opacity: 1;\n}\nhtml.is-animating .swup-transition-fade {\n  opacity: 0;\n}\n"
  },
  {
    "path": "src/utils/content.ts",
    "content": "import { getCollection } from 'astro:content'\n\n// 获取所有文章\nasync function getAllPosts() {\n  const allPosts = await getCollection('posts', ({ data }) => {\n    return import.meta.env.PROD ? data.draft !== true : true\n  })\n\n  return allPosts\n}\n\n// 获取所有文章，发布日期升序\nasync function getNewestPosts() {\n  const allPosts = await getAllPosts()\n\n  return allPosts.sort((a, b) => {\n    return a.data.date.valueOf() - b.data.date.valueOf()\n  })\n}\n\n// 获取所有文章，发布日期降序\nexport async function getOldestPosts() {\n  const allPosts = await getAllPosts()\n\n  return allPosts.sort((a, b) => {\n    return b.data.date.valueOf() - a.data.date.valueOf()\n  })\n}\n\n// 获取所有文章，置顶优先，发布日期降序\nexport async function getSortedPosts() {\n  const allPosts = await getAllPosts()\n\n  return allPosts.sort((a, b) => {\n    if (a.data.sticky !== b.data.sticky) {\n      return b.data.sticky - a.data.sticky\n    } else {\n      return b.data.date.valueOf() - a.data.date.valueOf()\n    }\n  })\n}\n\n// 获取所有文章的字数\nexport async function getAllPostsWordCount() {\n  const allPosts = await getAllPosts()\n\n  const promises = allPosts.map((post) => {\n    return post.render()\n  })\n\n  const res = await Promise.all(promises)\n\n  const wordCount = res.reduce((count, cur) => {\n    return count + cur.remarkPluginFrontmatter.words\n  }, 0)\n\n  return wordCount\n}\n\n// 转换为 URL 安全的 slug，删除点，空格转为短横线，大写转为小写\nexport function slugify(text: string) {\n  return text.replace(/\\./g, '').replace(/\\s/g, '-').toLowerCase()\n}\n\n// 获取所有分类\nexport async function getAllCategories() {\n  const newestPosts = await getNewestPosts()\n\n  const allCategories = newestPosts.reduce<{ slug: string; name: string; count: number }[]>(\n    (acc, cur) => {\n      if (cur.data.category) {\n        const slug = slugify(cur.data.category)\n        const index = acc.findIndex((category) => category.slug === slug)\n        if (index === -1) {\n          acc.push({\n            slug,\n            name: cur.data.category,\n            count: 1,\n          })\n        } else {\n          acc[index].count += 1\n        }\n      }\n      return acc\n    },\n    [],\n  )\n\n  return allCategories\n}\n\n// 获取所有标签\nexport async function getAllTags() {\n  const newestPosts = await getNewestPosts()\n\n  const allTags = newestPosts.reduce<{ slug: string; name: string; count: number }[]>(\n    (acc, cur) => {\n      cur.data.tags.forEach((tag) => {\n        const slug = slugify(tag)\n        const index = acc.findIndex((tag) => tag.slug === slug)\n        if (index === -1) {\n          acc.push({\n            slug,\n            name: tag,\n            count: 1,\n          })\n        } else {\n          acc[index].count += 1\n        }\n      })\n      return acc\n    },\n    [],\n  )\n\n  return allTags\n}\n\n// 获取热门标签\nexport async function getHotTags(len = 5) {\n  const allTags = await getAllTags()\n\n  return allTags\n    .sort((a, b) => {\n      return b.count - a.count\n    })\n    .slice(0, len)\n}\n"
  },
  {
    "path": "src/utils/date.ts",
    "content": "// 获取两个日期的相对时间\nexport function getRelativeTime(startDate: Date, endDate = new Date()) {\n  const diffSeconds = Math.floor((endDate.getTime() - startDate.getTime()) / 1000)\n  if (diffSeconds < 0) {\n    return null\n  }\n  const diffMinutes = Math.floor(diffSeconds / 60)\n  if (diffMinutes < 10) {\n    return '刚刚'\n  }\n  if (diffMinutes < 60) {\n    return `${diffMinutes} 分钟前`\n  }\n  const diffHours = Math.floor(diffMinutes / 60)\n  if (diffHours < 24) {\n    return `${diffHours} 小时前`\n  }\n  const diffDays = Math.floor(diffHours / 24)\n  if (diffDays < 10) {\n    return `${diffDays} 天前`\n  }\n  return null\n}\n\n// 获取一个格式化的日期，格式为：2024 年 1 月 1 日 星期一\nexport function getFormattedDate(date: Date) {\n  const year = date.getFullYear() % 100\n  const month = date.getMonth() + 1\n  const day = date.getDate()\n  const week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][date.getDay()]\n\n  return `${year} 年 ${month} 月 ${day} 日 ${week}`\n}\n\n// 数字前补 0\nfunction padZero(number: number, len = 2) {\n  return number.toString().padStart(len, '0')\n}\n\n// 获取格式化后的日期时间，格式：2024 年 01 月 01 日 12:00\nexport function getFormattedDateTime(date: Date) {\n  const year = date.getFullYear()\n  const month = padZero(date.getMonth() + 1)\n  const day = padZero(date.getDate())\n  const hours = padZero(date.getHours())\n  const minutes = padZero(date.getMinutes())\n\n  return `${year} 年 ${month} 月 ${day} 日 ${hours}:${minutes}`\n}\n\n// 获取两个日期的相差的天数\nexport function getDiffInDays(startDate: Date, endDate = new Date()) {\n  return Math.floor((endDate.getTime() - startDate.getTime()) / (1000 * 86400))\n}\n\n// 获取一个短的日期，格式为：04-20\nexport function getShortDate(date: Date) {\n  const month = padZero(date.getMonth() + 1)\n  const day = padZero(date.getDate())\n\n  return `${month}-${day}`\n}\n\n// 获取日期所在的年一共多少天\nexport function getDaysInYear(date: Date) {\n  const year = date.getFullYear()\n  if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {\n    return 366\n  }\n  return 365\n}\n\n// 获取日期所在的年的开始日期\nexport function getStartOfYear(date: Date) {\n  const year = date.getFullYear()\n  return new Date(year, 0, 1)\n}\n\n// 获取日期所在的天的开始日期\nexport function getStartOfDay(date: Date) {\n  return new Date(date.getFullYear(), date.getMonth(), date.getDate())\n}\n"
  },
  {
    "path": "src/utils/theme.ts",
    "content": "export function changePageTheme(theme: string) {\n  document.documentElement.setAttribute('data-theme', theme)\n}\n\nexport function getSystemTheme() {\n  return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'\n}\n\nconst themeKey = 'gyoza-theme'\n\nexport function getLocalTheme() {\n  const local = localStorage.getItem(themeKey)\n  if (local === 'dark' || local === 'light') {\n    return local\n  } else {\n    setLocalTheme('system')\n    return 'system'\n  }\n}\n\nexport function setLocalTheme(theme: string) {\n  localStorage.setItem(themeKey, theme)\n}\n"
  },
  {
    "path": "tailwind.config.ts",
    "content": "import type { Config } from 'tailwindcss'\n\nconst config: Config = {\n  content: ['./src/**/*.{astro,ts,tsx,js,jsx}'],\n  darkMode: ['selector', '[data-theme=\"dark\"]'],\n  theme: {\n    fontFamily: {\n      sans: [\n        '\"Noto Sans SC\"',\n        '\"Source Han Sans SC\"',\n        'sans-serif',\n        '\"Apple Color Emoji\"',\n        '\"Segoe UI Emoji\"',\n        '\"Segoe UI Symbol\"',\n        '\"Noto Color Emoji\"',\n      ],\n      serif: ['\"Noto Serif SC\"', '\"Source Han Serif SC\"', '\"Source Han Serif\"', 'serif'],\n      mono: ['\"JetBrains Mono\"', '\"Fira Code\"', 'Consolas', 'monospace'],\n    },\n    fontSize: {\n      xs: '0.75rem',\n      sm: '0.875rem',\n      base: '1rem',\n      lg: '1.125rem',\n      xl: '1.25rem',\n      '2xl': '1.5rem',\n      '3xl': '1.875rem',\n      '4xl': '2.25rem',\n      '5xl': '3rem',\n    },\n    extend: {\n      colors: {\n        accent: 'rgb(var(--color-accent) / <alpha-value>)',\n      },\n      textColor: {\n        primary: 'rgb(var(--color-text-primary))',\n        secondary: 'rgb(var(--color-text-secondary))',\n      },\n      backgroundColor: {\n        root: 'rgb(var(--color-bg-root))',\n        primary: 'rgb(var(--color-bg-primary))',\n        secondary: 'rgb(var(--color-bg-secondary))',\n      },\n      borderColor: {\n        primary: 'rgb(var(--color-border-primary))',\n      },\n      minHeight: {\n        main: 'calc(100vh - 200px)',\n      },\n      transitionProperty: {\n        'bg-color': 'background-color',\n      },\n      zIndex: {\n        '1': '1',\n      },\n    },\n  },\n}\n\nexport default config\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"extends\": \"astro/tsconfigs/strict\",\n  \"compilerOptions\": {\n    \"strictNullChecks\": true,\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"@/*\": [\"src/*\"]\n    },\n    \"jsx\": \"react-jsx\",\n    \"jsxImportSource\": \"react\"\n  },\n  \"include\": [\"src/**/*\"]\n}\n"
  }
]