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.
After cloning the project, install dependencies:
npm ci
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
WARNING! Use a blank Google Account when setting this up on Continuous Integration
- On the Node.js Quickstart page enable the Drive API
- Pick "COVID-19 Aid Workers Guide" as the new project name
- Select "Web Server" as the OAuth client
- Enter
https://resources.distributeaid.org
as Authorized Javascript Origin - Follow the Create the service account and credentials instructions and generate a key for the service account
- Store that file in the project folder as
jwt.keys.json
- Install pandoc
You can now run
node export-to-markdown.js
to export the Google Drive contents to the export
folder.
npx gatsby develop
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
.
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=...