- Make sure you have node and npm installed on your machine.
- Clone this repo by typing git clone https://github.com/processing/p5.js-website/ in your terminal. (You can also use GitHub Desktop).
- Then install the project's dependencies with:
npm install
Running this will start up a local dev server and print out the address in your terminal (for example: http://localhost:4321/). Open that page in your browser to see the website.
npm run dev
The website code is divided into a few main folders:
src/content/
this is where almost all content authoring happens in the repo. These files contain the content that is used to generate the website.src/components/
holds UI elements that are rendered on different pages of the website. Things like basic buttons, as well as more specialized things like the top navigation menus are here.src/layouts/
this contains the basic visual structure of each page. If you are looking to edit a specific page of the website, finding the layout for it in this folder is a great place to start.src/pages/
these files are primarily used to create the routes (the different URLs) for the pages of the website and pull content fromsrc/content/
. Note that every route basically exists twice: once insrc/pages/
and again insrc/[locale]/pages/
to support localized urls. Read more about this in [./localization-architecture.md]src/api/
holds the logic for fetching information from the OpenProcessing API, where all the gallery sketches for this website are storedsrc/i18n/
holds the utilities and configuration for working with translationssrc/scripts/
contains utility scripts that update the files insrc/content/
with changes in the p5.js repostyles/
contains globally applied css styles for the websitetest/
contains a set of unit tests that cover some important utility functions and key components
As you make changes to the code on the site, the page you see rendered in the browser from npm run dev
will update automatically. However, you may need to refresh to see some styling changes reflected.
You can check your work with the following commands. These will run type checking on typescript files and check for common mistakes in javascript files.
npm run lint
npm run check
To run the suite of unit tests, use:
npm run test
We are using the Astro framework as a static site generator, which means that the build process renders every single page of the website as HTML (and JavaScript and CSS) and then serves them using a simple server. These are then uploaded to GitHub Pages. This all happens automatically with GitHub Actions when code is merged to the main
branch in this repo.
You can try building the site locally with
npm run build
And then view it locally with
npm run preview