Skip to content

Commit a1a978a

Browse files
committed
Improved remix attribution schema
1 parent a30d22f commit a1a978a

File tree

3 files changed

+61
-18
lines changed

3 files changed

+61
-18
lines changed

src/content/examples/config.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@ export const examplesCollection = defineCollection({
1717
relatedReference: z.array(reference("reference")).optional(),
1818
featuredImage: image(),
1919
featuredImageAlt: z.string().optional().default(""),
20-
archiveAttributionPrefix: z.string().optional().default(""),
21-
archiveAttributionName: z.string().optional().default(""),
22-
archiveAttributionURL: z.string().optional().default(""),
23-
revisedAttributionPrefix: z.string().optional().default(""),
24-
revisedAttributionPrefixURL: z.string().optional().default(""),
25-
revisedAttributionName: z.string().optional().default(""),
26-
revisedAttributionURL: z.string().optional().default(""),
20+
// Optional list of remixes to add to license
21+
remix: z
22+
.array(
23+
z.object({
24+
attributionURL: z.string().optional(),
25+
attributionLabel: z.string().optional(),
26+
remixURL: z.string().optional(),
27+
remixLabel: z.string().optional(),
28+
})
29+
)
30+
.optional()
31+
.default([]),
2732
}),
2833
});
34+

src/content/examples/en/15_Math_And_Physics/03_Smoke_Particle_System/description.mdx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ featuredImageAlt: Rainbow colored smoke angled towards the right of the canvas,
44
title: Smoke Particles
55
oneLineDescription: Simulate smoke with a particle system.
66
featured: true
7-
archiveAttributionPrefix: Based on
8-
archiveAttributionName: Dan Shiffman's example
9-
archiveAttributionURL: https://natureofcode.com/book/chapter-4-particle-systems/
10-
revisedAttributionPrefix: Revised in 2023
11-
revisedAttributionPrefixURL: https://github.com/processing/p5.js-example
12-
revisedAttributionName: Darren Kessner
13-
revisedAttributionURL: https://github.com/dkessner
7+
remix:
8+
- attributionURL: https://github.com/dkessner
9+
attributionLabel: Darren Kessner
10+
remixURL: https://github.com/processing/p5.js-example
11+
remixLabel: Revised in 2023
12+
- attributionURL: https://natureofcode.com/book/chapter-4-particle-systems/
13+
attributionLabel: Dan Shiffman's example
14+
1415
---
1516

1617

src/layouts/ExampleLayout.astro

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,46 @@ const { Content } = await example.render();
6666
<div class="rendered-markdown">
6767
<p>
6868

69-
<a href={Astro.url.pathname}>{example.data.title}</a>:
70-
{example.data.archiveAttributionPrefix} <a href={example.data.archiveAttributionURL}>{example.data.archiveAttributionName}</a>.
71-
<a href={example.data.revisedAttributionPrefixURL}>{example.data.revisedAttributionPrefix}</a> by <a href={example.data.revisedAttributionURL}>{example.data.revisedAttributionName}</a>.
72-
From 2023 onwards, edited and maintained by <a href="https://github.com/processing/p5.js?tab=readme-ov-file#contributors">p5.js Contributors</a> and the <a href="https://processingfoundation.org/people">Processing Foundation</a>. Licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a>.
69+
<a href={Astro.url.pathname}>{example.data.title}</a>:
70+
Edited and maintained by
71+
<a href="https://github.com/processing/p5.js?tab=readme-ov-file#contributors">p5.js Contributors</a>
72+
and the
73+
<a href="https://processingfoundation.org/people">Processing Foundation</a>.
74+
Licensed under{" "}
75+
<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a>.
76+
77+
78+
{example.data.remix?.map((item, i) => (
79+
<>
80+
{i > 0 && " "}
81+
{item.remixLabel && item.remixURL ? (
82+
<>
83+
<a href={item.remixURL}>{item.remixLabel}</a>
84+
{item.attributionLabel && (
85+
<>
86+
{" "}by{" "}
87+
{item.attributionURL ? (
88+
<a href={item.attributionURL}>{item.attributionLabel}</a>
89+
) : (
90+
item.attributionName
91+
)}
92+
</>
93+
)}
94+
</>
95+
) : item.attributionLabel ? (
96+
<>
97+
Remixed from{" "}
98+
{item.attributionURL ? (
99+
<a href={item.attributionURL}>{item.attributionLabel}</a>
100+
) : (
101+
item.attributionName
102+
)}
103+
</>
104+
) : null}
105+
{i < example.data.remix.length - 1 && "."}
106+
</>
107+
))}
108+
73109

74110
</p>
75111
<img src="/images/by-nc-sa.svg" />

0 commit comments

Comments
 (0)