Skip to content

Commit ed423ae

Browse files
luoxuanzaoQoder-AI
andauthored
docs(site): add a theme-aware favicon (#89)
* docs(site): add a favicon so link cards show a thumbnail Chat apps such as DingTalk render the site icon as the link card thumbnail; the site emitted no favicon at all, so cards showed an empty slot while sibling sites on the same domain showed theirs. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com> * docs(site): make the favicon follow the browser color scheme A favicon has no surrounding text color for currentColor to inherit, so the synced icon now carries a prefers-color-scheme block: black mark on light browser chrome, white on dark, mirroring how the plugin icon picks up the vault theme. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com> --------- Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
1 parent d813f3b commit ed423ae

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎docs/docusaurus.config.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ const config = {
1414
projectName: "Qoderian",
1515
trailingSlash: false,
1616

17+
headTags: [
18+
{
19+
tagName: "link",
20+
attributes: {
21+
rel: "icon",
22+
type: "image/svg+xml",
23+
// headTags hrefs are emitted verbatim, so the baseUrl prefix is manual.
24+
href: "/Qoderian/img/favicon.svg",
25+
},
26+
},
27+
],
28+
1729
onBrokenLinks: "throw",
1830

1931
i18n: {

‎docs/scripts/sync-assets.mjs‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copies shared repository assets into the website's static dir so the
22
// published site can reference them without committing duplicates.
3-
import { copyFileSync, mkdirSync } from "node:fs";
3+
import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
44
import { dirname, join } from "node:path";
55
import { fileURLToPath } from "node:url";
66

@@ -19,3 +19,20 @@ for (const [from, to] of targets) {
1919
copyFileSync(join(repoRoot, from), dest);
2020
console.log(`synced ${from} -> docs/${to}`);
2121
}
22+
23+
// The favicon reuses the plugin icon, but a favicon has no surrounding text
24+
// color for currentColor to inherit, so the theme switch is made explicit:
25+
// black mark on light browser chrome, white on dark.
26+
const favicon = readFileSync(join(repoRoot, "src/assets/qoder-icon.svg"), "utf8")
27+
.replace('fill="currentColor"', 'class="qf"')
28+
.replace('stroke="currentColor"', 'class="qs"')
29+
.replace(
30+
/<svg[^>]*>/,
31+
(tag) =>
32+
`${tag}<style>.qf{fill:#000}.qs{fill:none;stroke:#000}` +
33+
"@media (prefers-color-scheme: dark){.qf{fill:#fff}.qs{stroke:#fff}}</style>",
34+
);
35+
const faviconDest = join(siteDir, "static/img/favicon.svg");
36+
mkdirSync(dirname(faviconDest), { recursive: true });
37+
writeFileSync(faviconDest, favicon);
38+
console.log("built src/assets/qoder-icon.svg -> docs/static/img/favicon.svg");

0 commit comments

Comments
 (0)