Skip to content

Commit 7e6147b

Browse files
authored
Merge pull request #1247 from doradocodes/1229-2.0
Merge PR #1229 to 2.0 branch
2 parents 4ff9332 + 8adb527 commit 7e6147b

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/content/text-detail/en/download.mdx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import {
77
cdnLibraryUrl,
88
fullDownloadUrl,
99
libraryDownloadUrl,
10-
minifiedLibraryDownloadUrl
10+
minifiedLibraryDownloadUrl,
11+
p5LatestUrl,
12+
p5MajorVersion
1113
} from '@src/globals/globals'
1214

1315
Welcome! This page contains the links to start using p5.js in the way that suits you best. Open the p5.js Editor in your web browser, or download the library to your own computer. We’ve tried to order the links to reflect what a beginner might want first, then what a more experienced programmer may be looking for.
@@ -30,11 +32,22 @@ These are downloads or links to the p5.js library file. No additional contents a
3032
<LinkButton variant='download' url={minifiedLibraryDownloadUrl}> p5.min.js </LinkButton>
3133
</div>
3234

33-
### Use p5.js from CDN
34-
p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing.
35+
## Use p5.js from CDN
36+
37+
All versions of p5.js are hosted on a content delivery network (CDN), a geographically distributed group of servers. There are a couple different ways to access the JavaScript library from your code editor.
38+
39+
### Current Version of p5.js (recommended)
40+
41+
Use the following URL if you'd like to access the current version of p5.js.
3542

3643
<CodeContainerWithCopy>{cdnLibraryUrl}</CodeContainerWithCopy>
3744

38-
### Older versions
39-
Looking for older versions?
40-
Head over to GitHub for [earlier releases](https://github.com/processing/p5.js/releases) of p5.js.
45+
### Latest Version of p5.js
46+
47+
Use the following URL if you'd like to ensure that you're always accessing the latest version of p5.js {p5MajorVersion}.x.
48+
49+
<CodeContainerWithCopy>{p5LatestUrl}</CodeContainerWithCopy>
50+
51+
### Other Versions of p5.js
52+
53+
If you'd like to access an earlier version of p5.js, you can look up the corresponding URL on [p5.js' jsDelivr webpage](https://www.jsdelivr.com/package/npm/p5).

src/globals/globals.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export const cdnSoundUrl =
2626
(!!import.meta.env?.PUBLIC_P5_LIBRARY_PATH || p5Version.startsWith('2'))
2727
? `https://cdn.jsdelivr.net/npm/p5.sound@${p5SoundVersion}/dist/p5.sound.min.js` as const
2828
: `https://cdn.jsdelivr.net/npm/p5@${p5Version}/lib/addons/p5.sound.min.js` as const
29+
export const p5MajorVersion =
30+
p5Version.split('.')[0];
31+
export const p5LatestUrl =
32+
`https://cdn.jsdelivr.net/npm/p5@${p5Version.split('.')[0]}/lib/p5.min.js` as const;
2933
export const cdnWebGPUUrl =
3034
import.meta.env?.PUBLIC_P5_WEBGPU_LIBRARY_PATH ||
3135
(`https://cdn.jsdelivr.net/npm/p5@${p5Version}/lib/p5.webgpu.min.js` as const);

0 commit comments

Comments
 (0)