Skip to content

Commit f868d6b

Browse files
committed
Add route for sound reference
1 parent 53b88c1 commit f868d6b

File tree

9 files changed

+29
-9
lines changed

9 files changed

+29
-9
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: p5.sound Reference
3+
---
4+
5+
Looking for the main p5.js reference? Go to <a href="/reference/">the reference</a>!

src/content/pages/en/reference.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
title: Reference
33
---
44

5-
Looking for p5.sound? Go to the <a href="https://archive.p5js.org/reference/#/libraries/p5.sound">p5.sound reference</a>!
5+
Looking for p5.sound? Go to the <a href="/reference/p5.sound/">p5.sound reference</a>!

src/content/reference/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const categories = [
2121
"Structure", // TODO: move to top once revised
2222
"Constants",
2323
"Foundation",
24-
"p5.sound",
2524
] as const;
2625

2726
const paramSchema = z.object({

src/content/ui/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ No Results: No entries found for that search.
4646
No alt text: No alt text
4747
briefPageDescriptions:
4848
Reference: Find easy explanations for every piece of p5.js code.
49+
p5.sound Reference: Extend p5.js with Web Audio functionality including audio input, playback, analysis and synthesis.
4950
Examples: Explore the possibilities of p5.js with short examples.
5051
Tutorials: Start from scratch or expand your skills with step-by-step lessons in p5.js.
5152
Contribute: Get involved with p5.js—create, code, document, donate, teach, and more!

src/globals/globals.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { p5Version } from "./p5-version";
1+
import { p5Version, p5SoundVersion } from "./p5-version";
22

33
export const contentTypes = [
44
"contributor-docs",
@@ -22,4 +22,4 @@ export const libraryDownloadUrl =
2222
export const minifiedLibraryDownloadUrl =
2323
`https://github.com/processing/p5.js/releases/download/v${p5Version}/p5.min.js` as const;
2424
export const cdnSoundUrl =
25-
`https://cdn.jsdelivr.net/npm/p5@${p5Version}/lib/addons/p5.sound.js` as const;
25+
`https://cdn.jsdelivr.net/npm/p5.sound.js@${p5SoundVersion}` as const;

src/globals/p5-version.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const p5Version = "1.11.0" as const;
2+
export const p5SoundVersion = "0.1.0" as const;

src/layouts/BaseLayout.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const {
3838
3939
const currentLocale = getCurrentLocale(Astro.url.pathname);
4040
41-
const slug = title.toLowerCase().split(/\s+/).join('-');
41+
const slug = title.toLowerCase().split(/\s+|\./).join('-');
4242
const pages = await getCollectionInLocaleWithFallbacks("pages", currentLocale);
4343
const headerPage = pages.find((page) => removeLocalePrefix(page.slug).slice(1) === slug);
4444
let HeaderContent: any = undefined;

src/layouts/ReferenceLayout.astro

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
interface Props {
2323
title: string;
2424
entries: CollectionEntry<"reference">[];
25+
categories?: string[];
2526
}
2627
2728
function strCompare(a: string, b: string) {
@@ -40,7 +41,7 @@ const uiTranslations = await getUiTranslationWithFallback(currentLocale);
4041
4142
const { entries } = Astro.props;
4243
43-
const categoryData = categories.map((category) => {
44+
const categoryData = (Astro.props.categories ?? categories).map((category) => {
4445
// Get all reference entries in the module
4546
const directEntries = entries.filter(
4647
(e) => e.data.module === t("referenceCategories", "modules", category)
@@ -135,7 +136,11 @@ const categoryData = categories.map((category) => {
135136
};
136137
});
137138
138-
const pageJumpToLinks: JumpToLink[] = categoryData.map((category) => ({
139+
const jumpCategoryData = categoryData.length === 1
140+
? [...categoryData, ...categoryData[0].subcats]
141+
: categoryData;
142+
143+
const pageJumpToLinks: JumpToLink[] = jumpCategoryData.map((category) => ({
139144
label: category.name as string,
140145
url: `#${category.name}`,
141146
}));
@@ -147,9 +152,9 @@ const pageJumpToState: JumpToState = {
147152
setJumpToState(pageJumpToState);
148153
---
149154

150-
<Head title="Reference" locale={currentLocale} />
155+
<Head title={Astro.props.title} locale={currentLocale} />
151156

152-
<BaseLayout title="Reference" mainContentParentClass="mx-0">
157+
<BaseLayout title={Astro.props.title} mainContentParentClass="mx-0">
153158
<ReferenceDirectoryWithFilter
154159
client:load
155160
categoryData={categoryData as any}

src/pages/reference/p5.sound.astro

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
import ReferenceLayout from "@layouts/ReferenceLayout.astro";
3+
import { getCollectionInDefaultLocale } from "@pages/_utils";
4+
5+
const entries = await getCollectionInDefaultLocale("reference");
6+
const soundEntries = entries.filter((e) => e.data.module === 'p5.sound')
7+
---
8+
9+
<ReferenceLayout title="p5.sound Reference" entries={soundEntries} categories={['p5.sound']} />

0 commit comments

Comments
 (0)