Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

distributeaid/covid-19-resources-drive-export

Repository files navigation

Converts the COVID-19 Aid Workers Guide to a static website

Publish Export Netlify Status Renovate Mergify Status Commitizen friendly code style: prettier

This projects turns the content in the Google Drive folder into a static website using Gatsby.js.

Read more about this project in this blog post.

Install dependencies

After cloning the project, install dependencies:

  npm ci

Set up the export

Using a copy of the export

Every time the website is published the export folder is zipped and published, which you can download:

  wget https://raw.githubusercontent.com/distributeaid/covid-19-resources-drive-export/gh-pages/export.zip
  unzip export.zip

Using the Google Drive API

WARNING! Use a blank Google Account when setting this up on Continuous Integration

  1. On the Node.js Quickstart page enable the Drive API
  2. Pick "COVID-19 Aid Workers Guide" as the new project name
  3. Select "Web Server" as the OAuth client
  4. Enter https://resources.distributeaid.org as Authorized Javascript Origin
  5. Follow the Create the service account and credentials instructions and generate a key for the service account
  6. Store that file in the project folder as jwt.keys.json
  7. Install pandoc

You can now run

  node export-to-markdown.js

to export the Google Drive contents to the export folder.

Start Gatsby

  npx gatsby develop

How this project works

The GitHub action that runs every hour to export a Google Drive folder to GitHub pages.

It downloads the folder and passes all Docs trough a converter to turn them into Markdown (there is some fine tuning involved to remove unwanted elements and clean up HTML).

It ends up as a bunch of Markdown files in the export folder.

Gatsby is configured in gatsby-node.js to collect the markdown files in the export folder and turn them into pages. In addition the static/README.md will be used as the start page.

All pages are rendered using the template src/templates/page.tsx.

Search

In addition, when building the version for production, the Algolia Pages index is filled based on the configuration in gatsby-config.js. For this to work these environment variables have to be configured:

  GATSBY_ALGOLIA_APP_ID=...
  GATSBY_ALGOLIA_SEARCH_KEY=...
  ALGOLIA_ADMIN_KEY=...