Development
Improve the site's structure, style and substance.
You need to consider several things to think about before you can work on a code-based contribution. This article has the basics, but you should also read all the other articles in this section.
Setting Up
Before you can work on the site, you'll need the following:
A copy of Git, and a GitHub account set up with an SSH key.
A code editor that can provide an adequate editing experience for Svelte projects. We recommend:
- Visual Studio Code, which we include recommended extensions for.
- IntelliJ IDEA Ultimate, which we include run configurations for.
If you feel we could improve the editing experience in your favourite editor by providing configuration files in this repository, please feel free to contact us or submit a Pull Request.
NodeJS, version 20.0.0 or later.
Corepack enabled for
pnpm
(run thecorepack enable
command in a terminal).
Once you've finished setting up the project requirements, please ensure the following:
- The project's dependencies are installed, using
pnpm install
. - You're able to build a copy of the site, using
pnpm build
. - The development server starts correctly, using
pnpm dev
.
Documentation
Be sure to also read the following articles:
Development Notes
When working on the project, you should be aware of the following:
The development server can be slow, especially if you've just started it. The production build will be considerably faster regardless, so try not to focus too much on this.
If things aren't rendering how you expect, the development server may still be optimising dependencies. This can take a while, and you may need to refresh the page a few times before it finishes.
While we do use TypeScript everywhere, it still exists on top of JavaScript, a weakly typed language. This means that, occasionally, you'll run into issues with the type system. Try your best to solve any typing issues that crop up, but remember that it isn't a requirement to get the site building.
The
markdown-layout.svelte
file is special, and a little broken. mdsvex, which handles components and pages written in Markdown, doesn't support TypeScript. This means that you'll run into errors if you try to use type hints orimport type
in themarkdown-layout.svelte
file, and you can do little about it other than suppressing the errors.When writing Remark and Rehype plugins, you should be aware of the following:
It is best to use a Remark plugin when you want to work with the AST used to translate Markdown to HTML.
It is best to use a Rehype plugin when you want to work with the HTML that was generated using the Markdown.
If you want to modify the AST, you'll need to iterate over and modify the
tree
passed to your plugin's function, instead of using thevisit
function fromunist-util-visit
. However, thevisit
function is useful for filtering over thetree
if you don't need to modify it.A good example of a simple plugin that modifies the
tree
is therehype-color-chips
plugin.
During development, the search index will quickly become out-of-date. To fix this, follow these steps:
- Stop the development server if it is running.
- Delete the
build/
folder. - Delete the
static/pagefind
folder. - Rebuild your local copy of the site using
pnpm build
. - Start the development server again.