.github | ||
content | ||
docs | ||
gatsby | ||
magicbook | ||
src | ||
static | ||
tests | ||
.gitignore | ||
.prettierrc | ||
errata.md | ||
gatsby-browser.js | ||
gatsby-config.js | ||
gatsby-node.js | ||
magicbook.json | ||
package-lock.json | ||
package.json | ||
postcss.config.js | ||
README.md | ||
tailwind.config.js |
The Nature of Code (2024 p5.js edition!)
This repository contains all the files for The Nature of Code book. The source content for the book is stored in a private Notion database and imported here as raw HTML files, which are then used to build the print PDF and Gatsby website.
If you are looking for the 2012 edition of The Nature of Code book, the website is archived here along with the GitHub source archive.
Errata
The Errata page tracks all uncorrected errors in the print edition since the publication date (September 3, 2024). If you would like to submit an error, please open an issue. All corrections must go through the Notion database, so unfortunately pull requests cannot be accepted.
Exercise Solutions
There are exercises throughout the book that are open-ended and have multiple creative solutions. If you would like to submit a solution for these exercises, please open an issue with the exercise number and a link to your p5.js sketch. For the sketch to be added to the website, it will be re-saved to the Nature of Code web editor account. Please leave your name and URLs in the code comments so you can be credited properly!
There is also a showcase on the Coding Train website, where you can submit creative interpretations of the book content and exercises.
Example Ports to Other Languages
The website includes a page with ports of the examples to other languages and environments.
If you would like to add a resource to this list, please open an issue with the links and information related to your port.
Book Build Process
Edit & Import
Content is stored in a Notion database with the following attributes:
- Type (
Page
|Chapter
): handled differently during builds, currently only used in the website build. - Title: defines the title
- Status (
Draft
|Published
): onlyPublished
content will be imported - File Name: defines the page sequence in a PDF build
- Slug: defines the path in the web page URL
Each entity also contains a page of its content, which is transformed into html
files based on the schema. The transformation script (nature-of-code/fetch-notion) is written in Node.js and utilized as a GitHub action.
Build
The following steps describe how to build the book and website. However, you will need to skip the import-notion-docs
step, as it requires the Notion API key associated with the book. You can find the latest HTML version of the book in /content
.
# Install Dependencies
npm install
# Build PDF (Magicbook) in `build` directory
npm run build:pdf
# Build Website in `public` directory
npm run build
Attributions
Icons used in this project:
🖍️ (Crayon), 🦜 (Parrot), and 🔎 (Magnifying glass) from OpenMoji – CC BY-SA 4.0