Skip to content

Commit

Permalink
manage 3rd-party license by content-collection
Browse files Browse the repository at this point in the history
  • Loading branch information
namachan10777 committed Jun 22, 2024
1 parent 8afd1dd commit d4e378a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 40 deletions.
15 changes: 15 additions & 0 deletions src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
5 changes: 5 additions & 0 deletions src/content/thirdparty/katex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
src: src/layouts/katex.css
from:
- title: KaTeX
href: https://github.com/KaTeX/KaTeX
license: MIT
8 changes: 8 additions & 0 deletions src/content/thirdparty/link-card.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions src/content/thirdparty/reset.yml
Original file line number Diff line number Diff line change
@@ -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
45 changes: 5 additions & 40 deletions src/pages/notice.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModuleInfos> {
return new Promise((resolve, reject) => {
Expand All @@ -24,43 +25,7 @@ async function checkLicense(): Promise<ModuleInfos> {
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");
---

<Base
Expand Down Expand Up @@ -89,14 +54,14 @@ const sourceLicenses: Record<
</thead>
<tbody
>{
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) => (
<tr>
{index === 0 ? (
<td rowspan={from.length}>
<Anchor href={sourceHref}>
<code class="source-file-name">{source}</code>
<code class="source-file-name">{src}</code>
</Anchor>
</td>
) : null}
Expand Down

0 comments on commit d4e378a

Please sign in to comment.