Repository navigation
feat: 新增查看原文链接和 CC 协议声明 - #29
Conversation
- Add avif MIME type support in RSS feed - Add comment explaining enclosure length: 0 rationale - Add width/height attributes to Card thumbnail to prevent CLS Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add viewSource config for raw markdown link (GitHub raw URL) - Add license config for CC BY-NC-SA 4.0 declaration - Create ViewSource.astro component with GitHub icon - Create License.astro component with official CC badge and post URL - Integrate components into PostDetails layout - Simplify BackToTopButton and move to TOC sidebar - Add tech stack info to Footer (Astro & AstroPaper) - Remove ShareLinks from post details - Update TableOfContents to support slot for BackToTopButton Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 分离 coverImageUrl(页面显示)和 ogImageUrl(meta 标签) - 页面封面图只在用户明确设置 ogImage 时才显示 - 动态 OG 图片仅用于 meta 标签,不影响页面显示 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 更新 README.md,添加特性列表和配置说明 - 完善 openspec/project.md 项目上下文 - 归档 add-source-link-and-license proposal - 创建 post-details spec Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 新增 .claude/commands/xhs-copy.md 小红书文案生成命令 - .gitignore 添加 xhs-images/ 目录 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a "View Source" link and CC BY-NC-SA 4.0 license declaration to blog posts, along with UI improvements and bug fixes for cover image handling.
Changes:
- Added ViewSource and License components with configuration options
- Fixed cover image display logic to separate user-defined cover images from OG meta tags
- Relocated BackToTopButton to the TableOfContents sidebar
- Enhanced Footer with copyright year range and technology stack credits
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/config.ts | Added viewSource and license configuration options |
| src/components/ViewSource.astro | New component for GitHub source file link |
| src/components/License.astro | New component displaying CC license badge and declaration |
| src/layouts/PostDetails.astro | Integrated new components, fixed cover image logic, reorganized layout structure |
| src/components/TableOfContents.astro | Added slot for embedding BackToTopButton |
| src/components/BackToTopButton.astro | Simplified styling, removed progress indicator, now embedded in TOC |
| src/components/Card.astro | Added width/height attributes to thumbnail images for better performance |
| src/components/Footer.astro | Added copyright year range and "Powered by" section |
| src/pages/rss.xml.ts | Added AVIF MIME type support and clarified comment about enclosure length |
| README.md | Updated feature list and added configuration documentation |
| openspec/project.md | Updated project context with current tech stack and conventions |
| openspec/specs/post-details/spec.md | New specification for View Source and License features |
| openspec/changes/archive/* | Archived change proposal, tasks, and specifications |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - 支持文章封面图(用户设置 ogImage 时显示) | ||
| - 支持目录(TOC)侧边栏 | ||
| - 支持 CC BY-NC-SA 4.0 协议声明 | ||
| - 支持查看原文(跳转 GitHub raw 文件) |
There was a problem hiding this comment.
The documentation mentions "跳转 GitHub raw 文件" (jump to GitHub raw file), but according to the specification, the feature should use "blob" view instead of "raw". Update the description to reflect the correct functionality, such as "跳转 GitHub 源文件" without specifically mentioning "raw".
|
|
||
| ## External Dependencies | ||
| [Document key external services, APIs, or systems] | ||
| - GitHub API: 用于部署和 raw 文件访问 |
There was a problem hiding this comment.
The External Dependencies section mentions "raw 文件访问" (raw file access), but the specification indicates the feature should use "blob" view. Update this to be more accurate, such as "GitHub 源文件访问" or remove the specific mention of "raw".
| src="https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png" | ||
| alt={licenseType} | ||
| class="h-8" | ||
| loading="lazy" |
There was a problem hiding this comment.
The Creative Commons license badge is loaded from an external URL (https://licensebuttons.net). Consider adding width and height attributes to the img tag to improve layout stability and prevent content layout shift during page load. The current image dimensions are 88x31 pixels based on the URL path.
| loading="lazy" | |
| loading="lazy" | |
| width="88" | |
| height="31" |
| viewSource: { | ||
| enabled: true, | ||
| text: "查看原文", | ||
| url: "https://github.com/xkcoding/MyBlog/raw/master/", |
There was a problem hiding this comment.
The configuration URL uses "raw" but the specification requires "blob" view. The spec states the URL format should be https://github.com/{owner}/{repo}/blob/{branch}/{filePath} for blob view (formatted Markdown with GitHub UI), but the current implementation uses "raw" which serves the unformatted file content. Change the URL to use "blob" instead of "raw" to match the specification and provide a better user experience with GitHub's rendered Markdown view.
| url: "https://github.com/xkcoding/MyBlog/raw/master/", | |
| url: "https://github.com/xkcoding/MyBlog/blob/master/", |
| <EditPost {hideEditPost} {post} class="max-sm:hidden" /> | ||
| <span | ||
| aria-hidden="true" | ||
| class:list={["max-sm:hidden", { hidden: !SITE.viewSource.enabled }]} |
There was a problem hiding this comment.
The separator before ViewSource should also check if hideEditPost is true. When EditPost is hidden, the separator should also be hidden to avoid displaying a separator with nothing before it. Consider adding hideEditPost to the hidden condition: { hidden: !SITE.viewSource.enabled || hideEditPost }.
| class:list={["max-sm:hidden", { hidden: !SITE.viewSource.enabled }]} | |
| class:list={[ | |
| "max-sm:hidden", | |
| { hidden: !SITE.viewSource.enabled || hideEditPost }, | |
| ]} |
| - 🔍 Pagefind 全文搜索 | ||
| - 📖 目录侧边栏(TOC) | ||
| - 🖼️ 文章封面图 & 动态 OG 图片 | ||
| - 📝 查看原文(跳转 GitHub raw 文件) |
There was a problem hiding this comment.
The feature name in README says "查看原文(跳转 GitHub raw 文件)" which mentions "raw 文件" (raw file), but according to the specification, it should use "blob" view instead of "raw". This documentation should be updated to reflect the correct functionality: "查看原文(跳转 GitHub 源文件)" or similar wording that doesn't specifically mention "raw".
| - 📝 查看原文(跳转 GitHub raw 文件) | |
| - 📝 查看原文(跳转 GitHub 源文件) |
避免页面加载时的布局偏移 (CLS) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Changes
新增组件
ViewSource.astro: 查看原文链接组件License.astro: CC 协议声明组件(含官方徽章)配置更新
config.ts: 新增viewSource和license配置项Bug 修复
coverImageUrl(页面显示) 和ogImageUrl(meta 标签)Test plan
🤖 Generated with Claude Code