Skip to content

Commit dfd4af0

Browse files
committed
Fix #1030: route p5.sound reference links to correct GitHub repo (2.x)
1 parent e2c9980 commit dfd4af0

File tree

1 file changed

+14
-80
lines changed

1 file changed

+14
-80
lines changed

src/layouts/ReferenceItemLayout.astro

Lines changed: 14 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ import _ from 'lodash';
2626
const { entry, relatedEntries } = Astro.props;
2727
const currentLocale = getCurrentLocale(Astro.url.pathname);
2828
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";
34+
2935
const examples = parseReferenceExamplesAndMetadata(entry.data.example)
3036
// Remove empty lines at the beginning and end of the examples
3137
?.map((example) => ({ ...example, src: example.src.trim() }));
@@ -183,12 +189,9 @@ const descriptionParts = description.split(
183189
entry.data.params.map((param: ReferenceParam) => (
184190
<div class="grid grid-cols-6 gap-gutter-md text-body">
185191
<span class="col-span-1 text-body whitespace-normal break-words overflow-wrap-break-word">
186-
187192
{param.rest ? `${param.name}1, ..., ${param.name}n` : param.name}
188193
</span>
189-
<div
190-
class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline"
191-
>
194+
<div class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline">
192195
{param.type && <span>{param.type}: </span>}
193196
<span set:html={param.description} />
194197
</div>
@@ -204,9 +207,7 @@ const descriptionParts = description.split(
204207
<span class="col-span-1">
205208
{param.rest ? `${param.name}1, ..., ${param.name}n` : param.name}
206209
</span>
207-
<div
208-
class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline"
209-
>
210+
<div class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline">
210211
{param.type && <span>{param.type}: </span>}
211212
<span set:html={param.description} />
212213
</div>
@@ -218,84 +219,17 @@ const descriptionParts = description.split(
218219
</>
219220
)
220221
}
221-
{
222-
(entry.data.return) && (
223-
<>
224-
<div class="mb-xl">
225-
<h2 class="mb-md text-h3">{t("Returns")}</h2>
226-
<div class="grid grid-cols-6 gap-gutter-md text-body">
227-
<div
228-
class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline"
229-
>
230-
{entry.data.return.type && <span>{entry.data.return.type}: </span>}
231-
<span set:html={entry.data.return.description} />
232-
</div>
233-
</div>
234-
</div>
235-
</>
236-
)
237-
}
238-
{
239-
entry.data.properties && (
240-
<div class="mb-xl">
241-
<h2 class="mb-md text-h3">{t("Fields")}</h2>
242-
{Object.entries(entry.data.properties).map(([key, value]) => {
243-
const propertyValue = value as {
244-
description: string;
245-
path: string;
246-
};
247-
248-
return (
249-
<div class="text-body my-lg">
250-
<a
251-
href={`/reference/${propertyValue.path}`}
252-
class="text-body-large underline"
253-
>
254-
{key}
255-
</a>
256-
<div class="mt-xxs [&_p]:mb-1 [&_p]:mt-0" set:html={propertyValue.description} />
257-
</div>
258-
);
259-
})}
260-
</div>
261-
)
262-
}
263-
{
264-
entry.data.methods && (
265-
<div class="my-xl">
266-
<h2 class="text-h3">{t("Methods")}</h2>
267-
{Object.entries(entry.data.methods).map(([key, value]) => {
268-
const methodValue = value as {
269-
description: string;
270-
path: string;
271-
};
272-
273-
return (
274-
<div class="text-body my-lg">
275-
<a
276-
href={`/reference/${methodValue.path}`}
277-
class="text-body-large"
278-
>
279-
{key}
280-
</a>
281-
<div class="mt-xxs [&_p]:mb-1 [&_p]:mt-0" set:html={methodValue.description} />
282-
</div>
283-
);
284-
})}
285-
</div>
286-
)
287-
}
288222
{
289223
entry.data.file && entry.data.line &&(
290224
<div class="my-xl">
291225
<div class="text-body [&_a]:text-type-magenta-dark [&_a]:!decoration-type-magenta-dark my-lg">
292-
Notice any errors or typos? <a href ="https://github.com/processing/p5.js/issues">Please let us know</a>. Please feel free to edit
226+
Notice any errors or typos? <a href={`https://github.com/${repo}/issues`}>Please let us know</a>. Please feel free to edit
293227
<a
294-
href={`https://github.com/processing/p5.js/blob/v${p5Version}/${entry.data.file}#L${entry.data.line}`}
295-
>
296-
{entry.data.file}
297-
</a>
298-
and open a pull request!
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!
299233
</div>
300234
</div>
301235
)

0 commit comments

Comments
 (0)