Commit ecf2cb2

HPCesia <me@hpcesia.com>
2026-09-26 15:03:58
posts: add license declare as footer
1 parent 32943d8
Changed files (2)
src
pages
[...locale]
src/pages/[...locale]/posts/[slug].astro
@@ -48,5 +48,14 @@ const { Content } = await render(entry);
 >
   <article>
     <Content />
+    <footer>
+      <small>
+        <p>License: {
+          typeof data.license === "string"
+          ? data.license
+          : <a href={data.license.link}>{data.license.name}</a>
+        }</p>
+      </small>
+    </footer>
   </article>
 </BaseLayout>
src/content.config.ts
@@ -52,6 +52,16 @@ const typCollection = (base: string) => (defineCollection({
       }
       return z.NEVER;
     }),
+    license: z.xor([
+      z.object({
+        name: z.string(),
+        link: z.url(),
+      }),
+      z.string(),
+    ]).default({
+      name: "CC BY-NC-SA 4.0",
+      link: "https://creativecommons.org/licenses/by-nc-sa/4.0/",
+    }),
   }),
 }));