Skip to content

Commit 522b0e4

Browse files
Merge branch 'processing:main' into main
2 parents e66a931 + 1dafaf3 commit 522b0e4

File tree

6 files changed

+226
-9
lines changed

6 files changed

+226
-9
lines changed

astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ if (shouldSkipCompress) {
1717

1818
// https://astro.build/config
1919
export default defineConfig({
20+
site: 'https://p5js.org',
2021
integrations: [
2122
preact({
2223
compat: true,

public/assets/img/p5js.png

27.1 KB
Loading

public/images/by-nc-sa.svg

Lines changed: 202 additions & 0 deletions
Loading

src/components/Head/index.astro

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface Props {
1010
1111
const {
1212
title,
13-
featuredImageSrc = "/favicon.svg",
13+
featuredImageSrc = "/assets/img/p5js.png",
1414
locale,
1515
description,
1616
} = Astro.props;
@@ -28,6 +28,9 @@ const t = await getUiTranslator(locale);
2828
const localizedTitle = t(title) as string;
2929
const localizedDescription =
3030
description || (t("briefPageDescriptions", title) as string);
31+
32+
const rootUrl = new URL('/', process.env.NODE_ENV === "production" ? Astro.site : Astro.url.href);
33+
const ogpImageSrc = new URL(featuredImageSrc, rootUrl);
3134
---
3235

3336
<head>
@@ -38,14 +41,14 @@ const localizedDescription =
3841
<meta name="description" content={localizedDescription} />
3942
<meta property="og:title" content={title} />
4043
<meta property="og:description" content={localizedDescription} />
41-
<meta property="og:image" content={featuredImageSrc} />
44+
<meta property="og:image" content={ogpImageSrc} />
4245
<meta property="og:url" content={Astro.url.href} />
4346
<meta property="og:type" content="website" />
4447
<meta property="og:locale" content={localeContentMap[locale]} />
4548
<meta name="twitter:card" content="summary_large_image" />
4649
<meta name="twitter:site" content="@p5xjs" />
4750
<meta name="twitter:title" content={title} />
4851
<meta name="twitter:description" content={localizedDescription} />
49-
<meta name="twitter:image" content={featuredImageSrc} />
52+
<meta name="twitter:image" content={ogpImageSrc} />
5053
<meta name="twitter:url" content={Astro.url.href} />
5154
</head>

src/layouts/ExampleLayout.astro

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,18 @@ const { Content } = await example.render();
6565
</div>
6666
<EditableSketch code={code} />
6767
<p>{example.data.arialabel}</p>
68+
<div class="rendered-markdown">
69+
<p>
70+
<a href={Astro.url.pathname}>{example.data.title}</a> by <a href="https://p5js.org/people">p5.js Contributors</a> and the <a href="https://processingfoundation.org/people">Processing Foundation</a> is licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a>.
71+
</p>
72+
<img src="/images/by-nc-sa.svg" />
73+
</div>
6874
</div>
6975
<div class="grid gap-y-4xl lg:gap-y-mb-3xl mt-2xl">
7076
{
7177
relatedReferences.length > 0 ? (
7278
<RelatedItems
73-
title={t("Related Reference") as string}
79+
title={t("Related References") as string}
7480
items={relatedReferences}
7581
/>
7682
) : null

src/pages/_utils.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ export const generateJumpToState = async (
339339
break;
340340
case "examples":
341341
categories = new Set(
342-
localeEntries.map((entry) => getExampleCategory(entry.slug)),
342+
localeEntries.map((entry) => getExampleCategory(entry.id)),
343343
);
344344
break;
345345
default:
@@ -365,23 +365,28 @@ export const generateJumpToState = async (
365365
// Loop through each category and add entries to the jumpToLinks
366366
for (const category of categories ?? []) {
367367
const categoryLinks = [] as JumpToLink[];
368+
const categoryLabel = getCategoryLabel(category);
368369
categoryLinks.push({
369-
label: getCategoryLabel(category),
370-
url: `/${collectionType}#${category}`,
370+
label: categoryLabel,
371+
url:
372+
collectionType === "examples"
373+
? `/${collectionType}/#${categoryLabel.toLowerCase()}`
374+
: `/${collectionType}/#${category}`,
371375
current: false,
372376
});
373377

374378
// Examples are a special case where subentries are only shown if they are in the current category
375379
if (
376380
collectionType !== "examples" ||
377-
category === getExampleCategory(currentEntrySlug)
381+
category === getExampleCategory(currentEntrySlug) ||
382+
category.toLowerCase() === getExampleCategory(currentEntrySlug)
378383
) {
379384
// Get all entries in the current category
380385
let currentCategoryEntries = localeEntries.filter(
381386
(entry) =>
382387
category ===
383388
(collectionType === "examples"
384-
? getExampleCategory(entry.slug)
389+
? getExampleCategory(entry.id)
385390
: // @ts-expect-error - We know that the category exists because of the collection type
386391
entry.data.category ?? ""),
387392
);

0 commit comments

Comments
 (0)