{"_id":"@chenenpei/astro-md-theme","_rev":"6-63f75ec5089d1556db26a32bce29e125","name":"@chenenpei/astro-md-theme","dist-tags":{"latest":"0.0.6"},"versions":{"0.0.1":{"name":"@chenenpei/astro-md-theme","version":"0.0.1","_id":"@chenenpei/astro-md-theme@0.0.1","maintainers":[{"name":"chenenpei","email":"chenenpei93@gmail.com"}],"dist":{"shasum":"98fd0af6908ecf99922470c81e7cf7ce7d931350","tarball":"https://registry.npmjs.org/@chenenpei/astro-md-theme/-/astro-md-theme-0.0.1.tgz","fileCount":17,"integrity":"sha512-OgVO1hVAXcr5E2ip5+5Yk0viU1qcvxwOMEtQ1XLQ1ikmHhd2K6Z/Z+47ICaSVaWWp8Txg1kzQXHHfCUDxW0FOg==","signatures":[{"sig":"MEYCIQCxuPZfecE8q9QCSS1IoO7kYqHowPTr0TUgqJFHB8uoSAIhAOAiIiE6hf/78ke7CQrxAHW/37HbYUMUKzYtsmcLLvVc","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55409},"type":"module","exports":{"./Post.astro":"./src/components/Post.astro","./Header.astro":"./src/components/Header.astro","./Layout.astro":"./src/components/Layout.astro","./PostCard.astro":"./src/components/PostCard.astro","./IntroCard.astro":"./src/components/IntroCard.astro","./tailwind.config":"./tailwind.config.mjs","./PaperSheet.astro":"./src/components/PaperSheet.astro","./styles/global.css":"./src/styles/global.css","./TestComponent.astro":"./src/components/TestComponent.astro","./templates/HomePage.astro":"./src/templates/HomePage.astro","./templates/AboutPage.astro":"./src/templates/AboutPage.astro","./templates/ArchivePage.astro":"./src/templates/ArchivePage.astro","./templates/PostDetailPage.astro":"./src/templates/PostDetailPage.astro"},"gitHead":"f30c85dd87e9a52c32fdee1ae4e1f07f2771cc8f","_npmUser":{"name":"chenenpei","email":"chenenpei93@gmail.com"},"_npmVersion":"11.6.2","description":"Astro MD Theme 的核心主题包 - 一个使用 Astro 和 Tailwind CSS 构建的简约博客主题。","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"astro":"^4.0.0","tailwindcss":"^3.4.0","@astrojs/tailwind":"^5.1.0","@tailwindcss/typography":"^0.5.19"},"peerDependencies":{"astro":"^4.0.0","tailwindcss":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/astro-md-theme_0.0.1_1767239457452_0.30657424016605583","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@chenenpei/astro-md-theme","version":"0.0.2","_id":"@chenenpei/astro-md-theme@0.0.2","maintainers":[{"name":"chenenpei","email":"chenenpei93@gmail.com"}],"dist":{"shasum":"1ad96de5bcf8a96350c183869f207be98f116161","tarball":"https://registry.npmjs.org/@chenenpei/astro-md-theme/-/astro-md-theme-0.0.2.tgz","fileCount":23,"integrity":"sha512-xySPBPCvx4s8j8caufx44jsMW+K1d8XqqnFJZN9Xuj+kH+yu68z91aJUhCI49Cw0e6wkB1Vg5q7kn2Bk4oMKvA==","signatures":[{"sig":"MEUCIB2RjICkEXWZlz4Hw7QITvV6fAXMnzimLT24cLWnownDAiEArD7pXTPOGRfVIa574m678jaci/XuJmz2KMdWSxltE8w=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":69759},"type":"module","exports":{"./i18n":"./src/i18n/index.ts","./Post.astro":"./src/components/Post.astro","./Header.astro":"./src/components/Header.astro","./Layout.astro":"./src/components/Layout.astro","./PostCard.astro":"./src/components/PostCard.astro","./IntroCard.astro":"./src/components/IntroCard.astro","./tailwind.config":"./tailwind.config.mjs","./PaperSheet.astro":"./src/components/PaperSheet.astro","./styles/global.css":"./src/styles/global.css","./TestComponent.astro":"./src/components/TestComponent.astro","./templates/HomePage.astro":"./src/templates/HomePage.astro","./templates/AboutPage.astro":"./src/templates/AboutPage.astro","./templates/ArchivePage.astro":"./src/templates/ArchivePage.astro","./templates/PostDetailPage.astro":"./src/templates/PostDetailPage.astro"},"gitHead":"15d7afd28713f9e93676902883597e880b082769","_npmUser":{"name":"chenenpei","email":"chenenpei93@gmail.com"},"_npmVersion":"11.6.2","description":"Astro MD Theme 的核心主题包 - 一个使用 Astro 和 Tailwind CSS 构建的简约博客主题。","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"astro":"^4.0.0","tailwindcss":"^3.4.0","@astrojs/tailwind":"^5.1.0","@tailwindcss/typography":"^0.5.19"},"peerDependencies":{"astro":"^4.0.0","tailwindcss":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/astro-md-theme_0.0.2_1767248404535_0.7938719821615297","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@chenenpei/astro-md-theme","version":"0.0.3","_id":"@chenenpei/astro-md-theme@0.0.3","maintainers":[{"name":"chenenpei","email":"chenenpei93@gmail.com"}],"dist":{"shasum":"94692a8c1c3df167e2915db33ae335bd80137c88","tarball":"https://registry.npmjs.org/@chenenpei/astro-md-theme/-/astro-md-theme-0.0.3.tgz","fileCount":24,"integrity":"sha512-jiiH6ZMjfB/3fys07hSxecscrNVX4Lb7bso1ENp4/Cvs6QFuKYmHgLFBl/rS1t+1OhuLfwTuNIgicU4x8ZxE0w==","signatures":[{"sig":"MEUCIQDa27yJ0zr7FiUde/Jc3PEIt1N92+nJBxgnj8WHm/T17QIgRg2uCqR7c2k2I8cUpC3ajDr1nIBGwkvqTZ1JU5Av5+c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":78737},"type":"module","exports":{"./i18n":"./src/i18n/index.ts","./utils/rss":"./src/utils/rss.ts","./Post.astro":"./src/components/Post.astro","./Header.astro":"./src/components/Header.astro","./Layout.astro":"./src/components/Layout.astro","./PostCard.astro":"./src/components/PostCard.astro","./IntroCard.astro":"./src/components/IntroCard.astro","./tailwind.config":"./tailwind.config.mjs","./PaperSheet.astro":"./src/components/PaperSheet.astro","./styles/global.css":"./src/styles/global.css","./TestComponent.astro":"./src/components/TestComponent.astro","./templates/HomePage.astro":"./src/templates/HomePage.astro","./templates/AboutPage.astro":"./src/templates/AboutPage.astro","./templates/ArchivePage.astro":"./src/templates/ArchivePage.astro","./templates/PostDetailPage.astro":"./src/templates/PostDetailPage.astro"},"gitHead":"4475d7f08166baee7372dc32b46a5972f50901e7","_npmUser":{"name":"chenenpei","email":"chenenpei93@gmail.com"},"_npmVersion":"11.6.2","description":"Astro MD Theme 的核心主题包 - 一个使用 Astro 和 Tailwind CSS 构建的简约博客主题。","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"astro":"^4.0.0","tailwindcss":"^3.4.0","@astrojs/tailwind":"^5.1.0","@tailwindcss/typography":"^0.5.19"},"peerDependencies":{"astro":"^4.0.0","tailwindcss":"^3.0.0","@astrojs/rss":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/astro-md-theme_0.0.3_1767277326807_0.12284145498745747","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@chenenpei/astro-md-theme","version":"0.0.4","_id":"@chenenpei/astro-md-theme@0.0.4","maintainers":[{"name":"chenenpei","email":"chenenpei93@gmail.com"}],"dist":{"shasum":"7d3983e203a381d12ad5d57ac9427a951b3729dc","tarball":"https://registry.npmjs.org/@chenenpei/astro-md-theme/-/astro-md-theme-0.0.4.tgz","fileCount":24,"integrity":"sha512-s3guZa3jougj5fj2U3c1JEsXF3CfZgGicx/9GZoZFdeeS8p6AIsuAexN+yKK1mH9miJR8wi/NNhrJLPEGZ1yGw==","signatures":[{"sig":"MEMCHwj9psSpZn5A49V4wSUkoZIPCZcOTawYSoEjilluhScCIBdkwGmFxuA077ucPk4KbMyW88wUioG46sdugUG9Bdjc","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":81069},"type":"module","exports":{"./i18n":"./src/i18n/index.ts","./utils/rss":"./src/utils/rss.ts","./Post.astro":"./src/components/Post.astro","./Header.astro":"./src/components/Header.astro","./Layout.astro":"./src/components/Layout.astro","./PostCard.astro":"./src/components/PostCard.astro","./IntroCard.astro":"./src/components/IntroCard.astro","./tailwind.config":"./tailwind.config.mjs","./PaperSheet.astro":"./src/components/PaperSheet.astro","./styles/global.css":"./src/styles/global.css","./TestComponent.astro":"./src/components/TestComponent.astro","./templates/HomePage.astro":"./src/templates/HomePage.astro","./templates/AboutPage.astro":"./src/templates/AboutPage.astro","./templates/ArchivePage.astro":"./src/templates/ArchivePage.astro","./templates/PostDetailPage.astro":"./src/templates/PostDetailPage.astro"},"gitHead":"2f329449494a205f8825c1585b4daa4cdff4ea16","_npmUser":{"name":"chenenpei","email":"chenenpei93@gmail.com"},"_npmVersion":"11.6.2","description":"Astro MD Theme 的核心主题包 - 一个使用 Astro 和 Tailwind CSS 构建的简约博客主题。","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"astro":"^4.0.0","tailwindcss":"^3.4.0","@astrojs/tailwind":"^5.1.0","@tailwindcss/typography":"^0.5.19"},"peerDependencies":{"astro":"^4.0.0","tailwindcss":"^3.0.0","@astrojs/rss":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/astro-md-theme_0.0.4_1767279248134_0.8492897588737678","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@chenenpei/astro-md-theme","version":"0.0.5","_id":"@chenenpei/astro-md-theme@0.0.5","maintainers":[{"name":"chenenpei","email":"chenenpei93@gmail.com"}],"dist":{"shasum":"cccabd689e4a81880ff44850812ec149b61aff08","tarball":"https://registry.npmjs.org/@chenenpei/astro-md-theme/-/astro-md-theme-0.0.5.tgz","fileCount":22,"integrity":"sha512-/WFZTKCw3oxoTRW/lJKGqC2CsiPbNVweBLfIZfGJGqdG3r6DNtai1xui3R97KR3OBMXlnTpIebLnJCiDOOLlCQ==","signatures":[{"sig":"MEYCIQDbHBlzjfo7eDpItuL7NOs1yWskyQH259IYcedRjgtBhwIhAKIO/y3T0/G+cQw7LugypvzgrcKBn8X/KOsZuK3KIR26","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":81669},"type":"module","exports":{"./i18n":"./src/i18n/index.ts","./utils/rss":"./src/utils/rss.ts","./Header.astro":"./src/components/Header.astro","./Layout.astro":"./src/components/Layout.astro","./PostCard.astro":"./src/components/PostCard.astro","./IntroCard.astro":"./src/components/IntroCard.astro","./tailwind.config":"./tailwind.config.mjs","./PaperSheet.astro":"./src/components/PaperSheet.astro","./styles/global.css":"./src/styles/global.css","./templates/HomePage.astro":"./src/templates/HomePage.astro","./templates/AboutPage.astro":"./src/templates/AboutPage.astro","./templates/ArchivePage.astro":"./src/templates/ArchivePage.astro","./templates/PostDetailPage.astro":"./src/templates/PostDetailPage.astro"},"gitHead":"8bb5676fba8e495a46aa68bac1668460a03160c4","_npmUser":{"name":"chenenpei","email":"chenenpei93@gmail.com"},"_npmVersion":"11.6.2","description":"Astro MD Theme 的核心主题包 - 一个使用 Astro 和 Tailwind CSS 构建的简约博客主题。","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"astro":"^4.0.0","tailwindcss":"^3.4.0","@astrojs/tailwind":"^5.1.0","@tailwindcss/typography":"^0.5.19"},"peerDependencies":{"astro":"^4.0.0","tailwindcss":"^3.0.0","@astrojs/rss":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/astro-md-theme_0.0.5_1767343015594_0.9054451883613526","host":"s3://npm-registry-packages-npm-production"}},"0.0.6":{"name":"@chenenpei/astro-md-theme","version":"0.0.6","type":"module","publishConfig":{"access":"public"},"exports":{"./Layout.astro":"./src/components/Layout.astro","./Header.astro":"./src/components/Header.astro","./PostCard.astro":"./src/components/PostCard.astro","./IntroCard.astro":"./src/components/IntroCard.astro","./PaperSheet.astro":"./src/components/PaperSheet.astro","./templates/HomePage.astro":"./src/templates/HomePage.astro","./templates/PostDetailPage.astro":"./src/templates/PostDetailPage.astro","./templates/ArchivePage.astro":"./src/templates/ArchivePage.astro","./templates/AboutPage.astro":"./src/templates/AboutPage.astro","./i18n":"./src/i18n/index.ts","./utils/rss":"./src/utils/rss.ts","./styles/global.css":"./src/styles/global.css","./tailwind.config":"./tailwind.config.mjs"},"peerDependencies":{"@astrojs/rss":"^2.0.0","astro":"^4.0.0","tailwindcss":"^3.0.0"},"devDependencies":{"@astrojs/tailwind":"^5.1.0","@tailwindcss/typography":"^0.5.19","astro":"^4.0.0","tailwindcss":"^3.4.0"},"gitHead":"0dbceef3eba4916bafd44b0472270206a6042a08","_id":"@chenenpei/astro-md-theme@0.0.6","description":"Astro MD Theme 的核心主题包 - 一个使用 Astro 和 Tailwind CSS 构建的简约博客主题。","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-4y6F82HlwQhHBP81O22Y6KeNyEdKUjDbhdE5af9FRrlwoudfGNSzM/0YCac4zTjzU2br8EspDl80aD2j/XAM0w==","shasum":"4b50a796d71544e577ae713e22a0f272379dbb77","tarball":"https://registry.npmjs.org/@chenenpei/astro-md-theme/-/astro-md-theme-0.0.6.tgz","fileCount":24,"unpackedSize":86686,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDfpRbjJTSZA7dzCTjHQZCqHBr+rD9ossQudH8VZ8DxowIhAPIVh5WpkhXLCEKbrCWjZBtlllyqKOTksTukEKJYwpsG"}]},"_npmUser":{"name":"chenenpei","email":"chenenpei93@gmail.com"},"directories":{},"maintainers":[{"name":"chenenpei","email":"chenenpei93@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/astro-md-theme_0.0.6_1767345719511_0.26391927721838737"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-01T03:50:57.316Z","modified":"2026-01-02T09:21:59.857Z","0.0.1":"2026-01-01T03:50:57.656Z","0.0.2":"2026-01-01T06:20:04.671Z","0.0.3":"2026-01-01T14:22:06.947Z","0.0.4":"2026-01-01T14:54:08.288Z","0.0.5":"2026-01-02T08:36:55.746Z","0.0.6":"2026-01-02T09:21:59.659Z"},"description":"Astro MD Theme 的核心主题包 - 一个使用 Astro 和 Tailwind CSS 构建的简约博客主题。","maintainers":[{"name":"chenenpei","email":"chenenpei93@gmail.com"}],"readme":"# @chenenpei/astro-md-theme\n\nAstro MD Theme 的核心主题包 - 一个使用 Astro 和 Tailwind CSS 构建的简约博客主题。\n\n## 📦 安装\n\n在你的 Astro 项目中，安装此包：\n\n```bash\npnpm add @chenenpei/astro-md-theme\n```\n\n或者使用 npm 或 yarn：\n\n```bash\nnpm install @chenenpei/astro-md-theme\n# 或\nyarn add @chenenpei/astro-md-theme\n```\n\n## 🚀 快速开始\n\n### 1. 安装依赖\n\n你还需要安装必需的 peer dependencies：\n\n```bash\npnpm add astro tailwindcss @astrojs/tailwind @tailwindcss/typography\n```\n\n数学公式支持（可选但推荐）：\n\n```bash\npnpm add remark-math rehype-katex\n```\n\n定义列表支持（可选）：\n\n```bash\npnpm add remark-definition-list\n```\n\n### 2. 配置 Astro\n\n更新你的 `astro.config.mjs`：\n\n```javascript\nimport { defineConfig } from 'astro/config';\nimport tailwind from '@astrojs/tailwind';\nimport remarkMath from 'remark-math';\nimport rehypeKatex from 'rehype-katex';\nimport remarkDefinitionList from 'remark-definition-list';\n\nexport default defineConfig({\n  integrations: [\n    tailwind({\n      applyBaseStyles: false, // 重要：禁用基础样式\n    }),\n  ],\n  markdown: {\n    remarkPlugins: [remarkMath, remarkDefinitionList],\n    rehypePlugins: [rehypeKatex],\n  },\n});\n```\n\n### 3. 导入全局样式\n\n在你的根布局或主页面中，导入主题的全局样式：\n\n```astro\n---\nimport '@chenenpei/astro-md-theme/styles/global.css';\n---\n```\n\n### 4. 使用主题组件\n\n在你的页面中导入并使用主题组件：\n\n**首页示例：**\n\n```astro\n---\nimport HomePage from '@chenenpei/astro-md-theme/templates/HomePage.astro';\nimport { getCollection } from 'astro:content';\n\nconst blogPosts = await getCollection('blog');\nconst posts = blogPosts\n  .sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime())\n  .slice(0, 3)\n  .map((post) => ({\n    title: post.data.title,\n    slug: post.slug,\n    excerpt: post.data.excerpt,\n    date: post.data.pubDate,\n    category: post.data.category,\n    coverImage: post.data.coverImage,\n  }));\n---\n\n<HomePage\n  siteTitle=\"我的空间\"\n  siteDescription=\"一个简约的博客主题\"\n  authorName=\"你的名字\"\n  authorBio=\"你的简介\"\n  posts={posts}\n/>\n```\n\n**文章详情页示例：**\n\n```astro\n---\nimport PostDetailPage from '@chenenpei/astro-md-theme/templates/PostDetailPage.astro';\nimport { getCollection } from 'astro:content';\n\nexport async function getStaticPaths() {\n  const blogPosts = await getCollection('blog');\n  \n  return Promise.all(blogPosts.map(async (post) => {\n    const { Content } = await post.render();\n    return {\n      params: { slug: post.slug },\n      props: { \n        post: {\n          slug: post.slug,\n          title: post.data.title,\n          date: post.data.pubDate,\n          category: post.data.category,\n          readingTime: post.data.readingTime,\n          coverImage: post.data.coverImage,\n          coverImageAlt: post.data.coverImageAlt,\n        },\n        content: Content\n      },\n    };\n  }));\n}\n\nconst { post, content: Content } = Astro.props;\n---\n\n<PostDetailPage\n  siteTitle=\"我的空间\"\n  title={post.title}\n  date={post.date}\n  category={post.category}\n  readingTime={post.readingTime}\n  coverImage={post.coverImage}\n  coverImageAlt={post.coverImageAlt}\n  slug={post.slug}\n>\n  <Content />\n</PostDetailPage>\n```\n\n### 5. 添加 KaTeX CSS（用于数学公式支持）\n\n在你的根布局（`src/layouts/Layout.astro` 或类似文件）中，添加 KaTeX CSS：\n\n```astro\n<head>\n  <!-- ... 其他 head 内容 ... -->\n  <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css\" />\n</head>\n```\n\n## 📚 可用组件\n\n### 模板\n\n- `HomePage.astro` - 带文章列表的首页模板\n- `PostDetailPage.astro` - 单篇文章页面模板\n- `ArchivePage.astro` - 归档页面模板\n- `AboutPage.astro` - 关于页面模板\n\n### 组件\n\n- `Layout.astro` - 根布局组件\n- `Header.astro` - 网站头部组件\n- `Footer.astro` - 网站页脚组件\n- `PostCard.astro` - 文章列表卡片组件\n- `IntroCard.astro` - 介绍卡片组件\n- `PaperSheet.astro` - 纸张风格的内容容器\n- `ScrollTopFab.astro` - 滚动到顶部浮动按钮组件\n\n## 🎨 特性\n\n- ✨ 现代、简约的设计\n- 📱 完全响应式布局\n- 🌓 暗色模式支持（自动主题切换）\n- 📝 丰富的 Markdown 支持：\n  - 带语法高亮的代码块\n  - 样式正确的表格\n  - 数学公式（LaTeX）支持（使用 KaTeX）\n  - 脚注\n  - 定义列表\n- 👆 滚动到顶部 FAB（浮动操作按钮）\n- 🦶 统一的页脚设计\n- 📡 RSS 订阅支持\n- 🎯 TypeScript 支持\n- ⚡ 快速的静态站点生成\n- 🎨 可通过 CSS 变量自定义\n\n## 📖 示例\n\n查看在线演示：[https://astro-md-theme-demo.netlify.app/](https://astro-md-theme-demo.netlify.app/)\n\n演示展示了所有功能，可以作为参考实现。\n\n## 🔧 自定义\n\n主题使用 CSS 变量以便于自定义。你可以在自己的 CSS 中覆盖它们：\n\n```css\n:root {\n  --header-bg: #121212;\n  --header-text: #FFFFFF;\n  --page-bg: #F4F4F4;\n  --card-bg: #FFFFFF;\n  --text-main: #121212;\n  --text-sec: #666666;\n  --accent: #0056b3;\n  --border: #e0e0e0;\n}\n```\n\n## 📡 RSS 支持\n\n主题提供了 RSS 生成工具函数，方便你为博客添加 RSS 订阅功能。\n\n### 安装依赖\n\n```bash\npnpm add @astrojs/rss\n```\n\n### 使用方法\n\n#### 1. 安装依赖\n\n```bash\npnpm add @astrojs/rss markdown-it sanitize-html\n```\n\n#### 2. 创建 RSS 端点\n\n在你的项目中创建 `src/pages/rss.xml.js`：\n\n```javascript\nimport rss from '@astrojs/rss';\nimport { getCollection } from 'astro:content';\nimport { SITE } from '../config';\nimport MarkdownIt from 'markdown-it';\nimport sanitizeHtml from 'sanitize-html';\n\nconst parser = new MarkdownIt({\n  html: true,     // 允许 HTML 标签\n  linkify: true,  // 自动转换 URL 为链接\n  typographer: true,  // 启用一些语言中立的替换和引号美化\n});\n\nexport async function GET(context) {\n  const posts = await getCollection('blog');\n\n  const rssItems = posts.map((post) => {\n    // 渲染 Markdown 为 HTML\n    const htmlContent = parser.render(post.body);\n\n    // 清理 HTML，保留安全的标签\n    const sanitizedContent = sanitizeHtml(htmlContent, {\n      allowedTags: sanitizeHtml.defaults.allowedTags.concat([\n        'img', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'\n      ]),\n      allowedAttributes: {\n        ...sanitizeHtml.defaults.allowedAttributes,\n        img: ['src', 'alt', 'title', 'width', 'height'],\n      },\n    });\n\n    return {\n      title: post.data.title,\n      link: `/blog/${post.slug}/`,\n      description: post.data.excerpt || post.data.description || post.data.title,\n      pubDate: post.data.pubDate,\n      content: sanitizedContent, // 完整的 HTML 内容\n    };\n  });\n\n  return rss({\n    title: SITE.title,\n    description: SITE.description,\n    site: context.site || SITE.url,\n    items: rssItems,\n  });\n}\n```\n\n### 完整内容支持\n\n通过使用 `markdown-it` 渲染 `post.body`，可以在 RSS 中包含完整文章内容。\n\n**注意事项**：\n- 使用 `getCollection()` 时，需要手动渲染 Markdown 为 HTML\n- MDX (`.mdx`) 文件无法用 `markdown-it` 渲染，建议仅包含摘要\n- 确保文章中的图片使用绝对路径（如 CDN、图床）或放在 `public/` 目录\n- `sanitize-html` 会清理危险的 HTML 标签，确保 RSS 内容安全\n\n### RSS 自动发现\n\n主题的 Layout 组件支持 RSS 自动发现功能。在调用 Layout 时传入 `rssPath` 参数：\n\n```astro\n---\nimport Layout from '@chenenpei/astro-md-theme/Layout.astro';\nimport { SITE } from '../config';\n---\n\n<Layout title={SITE.title} description={SITE.description} rssPath=\"/rss.xml\">\n  <slot />\n</Layout>\n```\n\n这会在 `<head>` 中添加：\n```html\n<link rel=\"alternate\" type=\"application/rss+xml\" title=\"Your Site\" href=\"/rss.xml\" />\n```\n\n### 可选工具函数\n\n主题还提供了可选的工具函数（按需使用）：\n\n```javascript\nimport { generateRSSFeed, blogToRSSItems } from '@chenenpei/astro-md-theme/utils/rss';\n\n// 简化 RSS 生成\nconst rssItems = blogToRSSItems(posts, {\n  limit: 20,        // 限制文章数量\n  locale: 'zh',     // 过滤特定语言\n  basePath: '/blog' // 自定义路径前缀\n});\n\nreturn generateRSSFeed({\n  title: SITE.title,\n  description: SITE.description,\n  site: context.site,\n  items: rssItems,\n});\n```\n\n## 📝 内容集合\n\n主题期望你的博客文章遵循以下 frontmatter 结构：\n\n```markdown\n---\ntitle: 文章标题\nexcerpt: 文章描述\npubDate: 2024-01-15\ncategory: 分类名称\nreadingTime: 5 mins\ncoverImage: https://example.com/image.jpg\ncoverImageAlt: 图片描述\n---\n\n你的文章内容...\n```\n\n## 🤝 贡献\n\n欢迎贡献！请随时提交 Pull Request。\n\n## 📄 许可证\n\nMIT\n\n---\n\n[English Documentation](README.md)\n","readmeFilename":"README.zh.md"}