Repository navigation
fix(theme): Linkcard 图标改为按域名命名的本地 SVG 自动发现 - #152
Merged
Merged
Conversation
- 删除组件内置的平台图标映射,改为 import.meta.glob 构建时自动发现 .vitepress/theme/icons/*.svg - 图标文件以域名命名(github.com.svg 等),子域名逐级回退主域名匹配 - 图片地址 logo 仍优先;未匹配到本地图标时回退站点 favicon,加载失败隐藏图标容器 - 同步 zh/en 的 markdown-features 与 about-docs 说明
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更说明
图标改为按域名命名、构建时自动发现,组件里不再维护平台图标映射。
问题背景
<Linkcard>未指定logo时会用https://${host}/favicon.ico取目标站点图标:discord.gg的 favicon 会重定向到discord.com并返回 HTML,<img>直接破图;x.com、t.me等站点在大陆网络受限或防盗链,请求经常失败;<img>没有error兜底,加载失败会留下破图线框。实现方式
.vitepress/theme/icons/(github.com.svg、x.com.svg、discord.gg.svg、t.me.svg、bilibili.com.svg),组件用import.meta.glob在构建时自动发现,新增平台图标只需放入同名 SVG;logo时按链接域名匹配本地图标:先精确匹配,再逐级去掉左侧子域回退主域名(www.x.com、space.bilibili.com都能命中);logo仍可直接传图片地址并优先使用,也可以填域名指定某个本地图标;currentColor内联 SVG,跟随深浅色主题,hover 过渡到品牌色;匹配不到本地图标时回退站点 favicon;<img>加载失败时隐藏图标容器,不再出现破图占位。文档同步
zh/contributing/markdown-features.md、en/contributing/markdown-features.md:更新logo参数说明,补充新增图标的方式;zh/about/about-docs.md、en/about/about-docs.md:同步组件行为描述。验证
pnpm docs:build通过(与 CI 一致);node scripts/docs-quality.mjs11 项门禁全部 0 违规;about/community.html与en/about/community.html各渲染 4 个本地图标,github.com/x.com/discord.gg/t.me的 favicon 请求全部消失;显式指定logo的卡片仍走<img>;