Skip to content

Commit

Permalink
Add RSS icon and clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
northword committed Jun 20, 2024
1 parent ddeac7c commit db12e7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { markdown } from "./config/markdown.config";
import { head } from "./config/head.config";
import vite from "./config/vite.config";

const RssIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 448 512"><title>RSS</title><path d="M400 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM112 416c-26.51 0-48-21.49-48-48s21.49-48 48-48s48 21.49 48 48s-21.49 48-48 48zm157.533 0h-34.335c-6.011 0-11.051-4.636-11.442-10.634c-5.214-80.05-69.243-143.92-149.123-149.123c-5.997-.39-10.633-5.431-10.633-11.441v-34.335c0-6.535 5.468-11.777 11.994-11.425c110.546 5.974 198.997 94.536 204.964 204.964c.352 6.526-4.89 11.994-11.425 11.994zm103.027 0h-34.334c-6.161 0-11.175-4.882-11.427-11.038c-5.598-136.535-115.204-246.161-251.76-251.76C68.882 152.949 64 147.935 64 141.774V107.44c0-6.454 5.338-11.664 11.787-11.432c167.83 6.025 302.21 141.191 308.205 308.205c.232 6.449-4.978 11.787-11.432 11.787z" fill="currentColor"></path></svg>`;

export default defineConfig({
title: "Zotero 中文社区",
description: "Zotero 非官方中文维护小组",
Expand Down Expand Up @@ -43,6 +45,7 @@ export default defineConfig({

socialLinks: [
{ icon: "github", link: "https://github.com/zotero-chinese/" },
{ icon: { svg: RssIcon }, link: "/rss.rss", ariaLabel: "RSS Feed" },
],

search: {
Expand Down
14 changes: 7 additions & 7 deletions .vitepress/config/buildEnd.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import path, { join } from "path";
import { writeFileSync } from "fs";
import { writeFileSync, copyFileSync } from "fs";
import { Feed } from "feed";
import {
createContentLoader,
createMarkdownRenderer,
type SiteConfig,
} from "vitepress";
import { createContentLoader, type SiteConfig } from "vitepress";
import { getGitTimestamp } from ".vitepress/utils/getGitTimestamp";
import { getDefaultTitle, getTextSummary } from ".vitepress/utils/markdown";
import FastGlob from "fast-glob";
Expand Down Expand Up @@ -77,6 +73,10 @@ export const buildEnd = async (config: SiteConfig) => {
});
}

writeFileSync(path.join(config.outDir, "rss.rss"), feed.rss2());
writeFileSync(path.join(config.outDir, "feed.rss"), feed.rss2());
copyFileSync(
path.join(config.outDir, "feed.rss"),
path.join(config.outDir, "rss.rss"),
);
console.log("🎉 RSS generated");
};

0 comments on commit db12e7a

Please sign in to comment.