Skip to content

Commit 2ead9ba

Browse files
authored
Merge branch 'main' into main
2 parents f416649 + da3c1aa commit 2ead9ba

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

src/components/PageHeader/RootPage.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const borderStyle = isFilterRoute ? "" : "border-b border-sidebar-type-color";
1212
---
1313

1414
<div
15-
class=`content-grid-simple min-h-[350px] h-[50vh] pt-[11.25rem] lg:pt-4xl bg-accent-color text-accent-type-color pb-md px-5 md:px-lg ${borderStyle}`
15+
class=`content-grid-simple min-h-[350px] pt-[11.25rem] lg:pt-4xl bg-accent-color text-accent-type-color pb-md px-5 md:px-lg ${borderStyle}`
1616
>
1717
<h1 class="whitespace-pre-line col-span-full mb-5">{title}</h1>
1818
<p class="text-h3 !mt-0 mb-3xl col-span-2">{subtitle}</p>

src/content/tutorials/en/conditionals-and-interactivity.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ function draw() {
524524

525525
  fill("green");
526526

527-
  rect(0, horizon, 400, 400);
527+
  rect(0, horizon, 400, 200);
528528

529529
}
530530
```

src/content/tutorials/en/repeating-with-loops.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Above `setup()`:
199199
In `draw()`:
200200

201201
- After the code that draws the finish line, declare a new local variable `x` to position all the body segments: `let x = circX;`
202-
- Add a *for loop* using: `for (let i = 0; i < length; i += 1) { }`
202+
- Add a *for loop* using: `for (let i = 0; i < segments; i += 1) { }`
203203
- A *for loop* will repeat the code we write inside the curly brackets multiple times. 
204204
- Move the lines of code that draw the `circle()` into the curly brackets of the *for loop*.
205205
- After the for loop, add: `circX += spacing` 
@@ -936,7 +936,7 @@ function moveCaterpillars() {
936936
  for (let i = 0; i < numCaterpillars; i += 1) {
937937
    //Give each caterpillar a
938938
    //random speed.
939-
    move = random(5, 30);
939+
    let move = random(5, 30);
940940
    caterpillarEnds[i] += move;
941941
}
942942
}
@@ -1001,7 +1001,7 @@ function moveCaterpillars() {
10011001
  for (let i = 0; i < numCaterpillars; i += 1) {
10021002
    //Give each caterpillar a
10031003
    //random speed.
1004-
    move = random(5, 30);
1004+
    let move = random(5, 30);
10051005
10061006
    // Update caterpillars' x-coordinates
10071007
    caterpillarEnds[i] += move;

src/layouts/ReferenceItemLayout.astro

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ const { showBanner, englishUrl } = checkTranslationBanner(
9090
Astro.url.pathname,
9191
Astro.url.origin
9292
);
93+
// Normalizes malformed p5.* reference anchors (e.g. "#/p5.Element")
94+
// to proper reference routes ("/reference/p5/p5.Element/")
95+
function normalizeP5ReferenceLinks(html: string | undefined): string | undefined {
96+
if (!html) return html;
97+
return html.replace(
98+
/href="#\/(p5\.[^"]+)"/g,
99+
'href="/reference/p5/$1/"'
100+
);
101+
}
93102
---
94103

95104
<Head title={entry.data.title} locale={currentLocale} />
@@ -196,7 +205,7 @@ const { showBanner, englishUrl } = checkTranslationBanner(
196205
class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline"
197206
>
198207
{param.type && <span>{param.type}: </span>}
199-
<span set:html={param.description} />
208+
<span set:html={normalizeP5ReferenceLinks(param.description)} />
200209
</div>
201210
</div>
202211
))}
@@ -212,7 +221,7 @@ const { showBanner, englishUrl } = checkTranslationBanner(
212221
class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline"
213222
>
214223
{param.type && <span>{param.type}: </span>}
215-
<span set:html={param.description} />
224+
<span set:html={normalizeP5ReferenceLinks(param.description)} />
216225
</div>
217226
</div>
218227
)
@@ -232,7 +241,7 @@ const { showBanner, englishUrl } = checkTranslationBanner(
232241
class="col-span-5 [&_p]:m-0 [&_p]:inline [&_a]:underline"
233242
>
234243
{entry.data.return.type && <span>{entry.data.return.type}: </span>}
235-
<span set:html={entry.data.return.description} />
244+
<span set:html={normalizeP5ReferenceLinks(entry.data.return.description)} />
236245
</div>
237246
</div>
238247
</div>

src/pages/_utils-node.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ export const removeNestedReferencePaths = (route: string): string =>
4545
route.replace(/constants\/|types\//, "")
4646

4747
export const rewriteRelativeLink = (url: string): string => {
48-
let updatedUrl: string;
48+
let updatedUrl: string = url;
4949

50-
if (/^((https?:\/)?)\//.exec(url) || url.startsWith('mailto:')) {
51-
// Leave absolute paths alone
52-
updatedUrl = url;
53-
} else if (url.startsWith('#')) {
54-
// Leave links to headings alone
50+
if (/^(https?:|mailto:|\/\/)/.exec(url)) {
51+
// Skip rewriting for external URLs (http(s), mailto)
52+
return url;
53+
} else if (url.startsWith('#')||url.startsWith('/')) {
54+
// Skip rewriting for heading links and root-relative internal paths
5555
updatedUrl = url;
5656
} else {
5757
// Convert relative paths to '../' (because pages that started as files in the same directory
@@ -81,4 +81,4 @@ export const rewriteRelativeLink = (url: string): string => {
8181
}
8282

8383
return updatedUrl;
84-
};
84+
};

styles/global.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ section,
230230
h2,
231231
.text-h2 {
232232
margin-top: var(--gutter-md);
233-
margin-bottom: 0px;
233+
margin-bottom: var(--spacing-md);
234234
}
235235

236236
h2,

0 commit comments

Comments
 (0)