Skip to content

Commit 8b1cc9d

Browse files
committed
Fix p5.sound reference source links to point to p5.sound.js repo
1 parent dfd4af0 commit 8b1cc9d

1 file changed

Lines changed: 87 additions & 14 deletions

File tree

src/layouts/ReferenceItemLayout.astro

Lines changed: 87 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ import _ from 'lodash';
2525
2626
const { entry, relatedEntries } = Astro.props;
2727
const currentLocale = getCurrentLocale(Astro.url.pathname);
28-
29-
/* 🔧 FIX #1030: choose correct GitHub repo for source links */
30-
const repo =
31-
entry.data.module === "p5.sound"
32-
? "processing/p5.sound"
33-
: "processing/p5.js";
28+
const isSound = entry.data.module === "p5.sound";
29+
const githubRepo = isSound
30+
? "processing/p5.sound.js"
31+
: "processing/p5.js";
32+
const githubRef = isSound
33+
? "main"
34+
: `v${p5Version}`;
3435
3536
const examples = parseReferenceExamplesAndMetadata(entry.data.example)
3637
// Remove empty lines at the beginning and end of the examples
@@ -189,9 +190,12 @@ const descriptionParts = description.split(
189190
entry.data.params.map((param: ReferenceParam) => (
190191
<div class="grid grid-cols-6 gap-gutter-md text-body">
191192
<span class="col-span-1 text-body whitespace-normal break-words overflow-wrap-break-word">
193+
192194
{param.rest ? `${param.name}1, ..., ${param.name}n` : param.name}
193195
</span>
194-
<div class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline">
196+
<div
197+
class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline"
198+
>
195199
{param.type && <span>{param.type}: </span>}
196200
<span set:html={param.description} />
197201
</div>
@@ -207,7 +211,9 @@ const descriptionParts = description.split(
207211
<span class="col-span-1">
208212
{param.rest ? `${param.name}1, ..., ${param.name}n` : param.name}
209213
</span>
210-
<div class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline">
214+
<div
215+
class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline"
216+
>
211217
{param.type && <span>{param.type}: </span>}
212218
<span set:html={param.description} />
213219
</div>
@@ -219,17 +225,84 @@ const descriptionParts = description.split(
219225
</>
220226
)
221227
}
228+
{
229+
(entry.data.return) && (
230+
<>
231+
<div class="mb-xl">
232+
<h2 class="mb-md text-h3">{t("Returns")}</h2>
233+
<div class="grid grid-cols-6 gap-gutter-md text-body">
234+
<div
235+
class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline"
236+
>
237+
{entry.data.return.type && <span>{entry.data.return.type}: </span>}
238+
<span set:html={entry.data.return.description} />
239+
</div>
240+
</div>
241+
</div>
242+
</>
243+
)
244+
}
245+
{
246+
entry.data.properties && (
247+
<div class="mb-xl">
248+
<h2 class="mb-md text-h3">{t("Fields")}</h2>
249+
{Object.entries(entry.data.properties).map(([key, value]) => {
250+
const propertyValue = value as {
251+
description: string;
252+
path: string;
253+
};
254+
255+
return (
256+
<div class="text-body my-lg">
257+
<a
258+
href={`/reference/${propertyValue.path}`}
259+
class="text-body-large underline"
260+
>
261+
{key}
262+
</a>
263+
<div class="mt-xxs [&_p]:mb-1 [&_p]:mt-0" set:html={propertyValue.description} />
264+
</div>
265+
);
266+
})}
267+
</div>
268+
)
269+
}
270+
{
271+
entry.data.methods && (
272+
<div class="my-xl">
273+
<h2 class="text-h3">{t("Methods")}</h2>
274+
{Object.entries(entry.data.methods).map(([key, value]) => {
275+
const methodValue = value as {
276+
description: string;
277+
path: string;
278+
};
279+
280+
return (
281+
<div class="text-body my-lg">
282+
<a
283+
href={`/reference/${methodValue.path}`}
284+
class="text-body-large"
285+
>
286+
{key}
287+
</a>
288+
<div class="mt-xxs [&_p]:mb-1 [&_p]:mt-0" set:html={methodValue.description} />
289+
</div>
290+
);
291+
})}
292+
</div>
293+
)
294+
}
222295
{
223296
entry.data.file && entry.data.line &&(
224297
<div class="my-xl">
225298
<div class="text-body [&_a]:text-type-magenta-dark [&_a]:!decoration-type-magenta-dark my-lg">
226-
Notice any errors or typos? <a href={`https://github.com/${repo}/issues`}>Please let us know</a>. Please feel free to edit
299+
Notice any errors or typos? <a href={`https://github.com/${githubRepo}/issues`}>Please let us know</a>. Please feel free to edit
227300
<a
228-
href={`https://github.com/${repo}/blob/v${p5Version}/${entry.data.file}#L${entry.data.line}`}
229-
>
230-
{entry.data.file}
231-
</a>
232-
and open a pull request!
301+
href={`https://github.com/${githubRepo}/blob/${githubRef}/${entry.data.file}#L${entry.data.line}`}
302+
>
303+
{entry.data.file}
304+
</a>
305+
and open a pull request!
233306
</div>
234307
</div>
235308
)

0 commit comments

Comments
 (0)