Skip to content

Website

Note: This page is mirrored from the next-website-v2 README. Please make edits there.

This repository contains the scaffolding for DA’s new website, powered by Next.js, TypeScript & Strapi. For most information about contributing to DA (e.g. our dev process and asking for help), please refer first to the general contributing guide.

Terminal window
git clone https://github.com/distributeaid/next-website-v2.git

This setup comes preconfigured with Next.js, TypeScript, Tailwind, and Next’s Incremental Static Regeneration.

To run a Next.js project you’ll need to install or update these dependencies:

Here are the steps to set up the project in your local dev environment:

  1. Install Dependencies:
Terminal window
yarn install
  1. Then run the development server to launch your app:
Terminal window
yarn dev
  1. Open http://localhost:3000 with your browser to see the result. The page auto-updates as you edit the file.

In order to exercise local code using custom environment variables, you’ll need to add an .env.yarn file at the project root containing the relevant variables.

  • Avoid using raw #hexadecimal values. View /src/stylesheets/ or tailwind.config.ts to see color value names.
  • Use Radix UI’s component library and use tailwind CSS for supplementary styling.

We are using a Next project structure.

  • /public/ - Contains images and documents that are used in different pages or components.
  • /src/ - Most of the files you’ll be working with live inside the /src/ folder.
  • /src/app/ - Contains the main pages for routing, meaning /src/app/[foldername]/page.tsx would route to the /[foldername] page on the website.
  • src/app/api - Any server-side code should be sequestered in src/app/api; i.e. logic for the contact form.
  • /src/components/ - Each page is made up of multiple components that will be imported onto that specific page.
  • /src/data - Anything data-related should live in /src/data, rather than inline in components.

To check types:

Terminal window
yarn check:types

To run the linter:

Terminal window
yarn lint

Check formatting:

Terminal window
yarn check:format
yarn format

To run tests:

Terminal window
yarn test

To add a new admin user to one of the webservers:

  1. SSH into the server

    Terminal window
    ssh your-username@server-address
  2. Add new admin

    Terminal window
    sudo adduser new-username
    sudo usermod -aG sudo new-username
  3. Confirm it works

    Terminal window
    id new-username
  4. Add to AllowUsers setting for ssh access

    Terminal window
    sudo vim /etc/ssh/sshd_config
    sudo systemctl reload ssh
  5. Add their public ssh key

    Terminal window
    sudo su - new-username
    mkdir -p ~/.ssh && chmod 700 ~/.ssh && touch ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys
    vim ./.ssh/authorized_keys
    exit
  6. (Optional) log out of the server

    Terminal window
    exit

To deploy the website on the staging or production server:

  1. SSH into the server

    Terminal window
    ssh your-username@server-address
  2. Change to the deploy user

    Terminal window
    sudo su - deploy
  3. Update the relevant branch

    Terminal window
    cd ./next-website-v2/
    git branch
    git checkout main # or the branch you want
    git pull
    yarn install
  4. Build and deploy the site

    Terminal window
    yarn build
    pm2 list
    pm2 restart 0 # or id of instance you want to restart
  5. Visit the site to make sure it works.

  6. Log out of the deploy user, and optionally the server

    Terminal window
    exit
    exit