diff --git a/src/content/config.ts b/src/content/config.ts index 6bf9693c..da403dca 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -34,8 +34,23 @@ const event = defineCollection({ }), }); +const thirdparty = defineCollection({ + type: "data", + schema: z.object({ + src: z.string(), + from: z.array( + z.object({ + title: z.string(), + href: z.string().url(), + license: z.literal("MIT"), + }), + ), + }), +}); + export const collections = { post, pub, event, + thirdparty, }; diff --git a/src/content/thirdparty/katex.yml b/src/content/thirdparty/katex.yml new file mode 100644 index 00000000..557bb76b --- /dev/null +++ b/src/content/thirdparty/katex.yml @@ -0,0 +1,5 @@ +src: src/layouts/katex.css +from: + - title: KaTeX + href: https://github.com/KaTeX/KaTeX + license: MIT diff --git a/src/content/thirdparty/link-card.yml b/src/content/thirdparty/link-card.yml new file mode 100644 index 00000000..69a4b1e2 --- /dev/null +++ b/src/content/thirdparty/link-card.yml @@ -0,0 +1,8 @@ +src: src/remark/plugin/link-card.ts +from: + - title: haxibami.net + href: https://github.com/haxibami/haxibami.net/blob/main/src/lib/remark-link-card.ts + license: MIT + - title: haxibami.net + href: https://github.com/haxibami/haxibami.net/blob/main/src/lib/mdast-util-node-is.ts + license: MIT diff --git a/src/content/thirdparty/reset.yml b/src/content/thirdparty/reset.yml new file mode 100644 index 00000000..c137a95e --- /dev/null +++ b/src/content/thirdparty/reset.yml @@ -0,0 +1,5 @@ +src: src/layouts/reset.css +from: + - title: The New Reset CSS + href: "https://github.com/elad2412/the-new-css-reset" + license: MIT diff --git a/src/pages/notice.astro b/src/pages/notice.astro index c295a027..06eddf37 100644 --- a/src/pages/notice.astro +++ b/src/pages/notice.astro @@ -4,6 +4,7 @@ import Anchor from "@components/mdx/anchor.astro"; import Heading1 from "@components/mdx/heading1.astro"; import Heading2 from "@components/mdx/heading2.astro"; import licenseChecker, { type ModuleInfos } from "license-checker-rseidelsohn"; +import { getCollection } from "astro:content"; async function checkLicense(): Promise { return new Promise((resolve, reject) => { @@ -24,43 +25,7 @@ async function checkLicense(): Promise { const moduleInfos = await checkLicense(); -const sourceLicenses: Record< - string, - { from: { title: string; href: string; license: string }[] } -> = { - "src/remark/plugin/link-card.ts": { - from: [ - { - title: "haxibami.net", - href: "https://github.com/haxibami/haxibami.net/blob/main/src/lib/remark-link-card.ts", - license: "MIT", - }, - { - title: "haxibami.net", - href: "https://github.com/haxibami/haxibami.net/blob/main/src/lib/mdast-util-node-is.ts", - license: "MIT", - }, - ], - }, - "src/layouts/reset.css": { - from: [ - { - title: "The new reset css", - href: "https://github.com/elad2412/the-new-css-reset", - license: "MIT", - }, - ], - }, - "src/layouts/katex.css": { - from: [ - { - title: "KaTeX", - href: "https://github.com/KaTeX/KaTeX", - license: "MIT", - }, - ], - }, -}; +const sourceLicenses = await getCollection("thirdparty"); --- { - Object.entries(sourceLicenses).map(([source, { from }]) => { - const sourceHref = `https://github.com/namachan10777/namachan10777.dev/blob/master/${source}`; + sourceLicenses.map(({ data: { src, from } }) => { + const sourceHref = `https://github.com/namachan10777/namachan10777.dev/blob/master/${src}`; return from.map(({ title, href, license }, index) => ( {index === 0 ? ( - {source} + {src} ) : null}