项目作者: meedan

项目描述 :
Covid-19 Expert Database
高级语言: HTML
项目地址: git://github.com/meedan/covid-19-expert-database.git
创建时间: 2020-05-12T17:28:35Z
项目社区:https://github.com/meedan/covid-19-expert-database

开源协议:

下载


This is a build system for Covid-19 Expert Database

This environment uses Jekyll with Contentful, Airtable and Algolia. For Contentful, it uses Contentful’s Jekyll-Contentful-Data-Import plugin. See the readme on the repository page to learn how to configure data import.

For Airtable, it uses a modified version of Airtable Fetch plugin.

And for Algolia, it uses Jekyll Algolia Plugin. It’s documentation outlines how to configure the plugin and how to send only the relevant data and how to theme the search ui.

Quick start

  1. Install Ruby 2.x (eg with rvm)
  2. bundle install or bundle install --path vendor/bundle to install all the packages
  3. Set environment variables to your shell’s configuration file (.bashrc or .bash_profile) for contentful, airtable and algolia:
  1. export CONTENTFUL_M_SPACE_ID=abc123
  2. export CONTENTFUL_M_ACCESS_TOKEN=abc123
  3. export CONTENTFUL_API_URL="cdn.contentful.com"
  4. export ALGOLIA_APPLICATION_ID=abc123
  5. export ALGOLIA_API_KEY=abc123
  6. export ALGOLIA_SEARCH_ONLY_API_KEY=abc123
  7. export ALGOLIA_INDEX_NAME_QUESTIONS=covid19_dev
  8. export ALGOLIA_INDEX_NAME_GLOSSARY=covid19_glossary_dev
  9. export AIRTABLE_API_KEY=abc123
  10. export AIRTABLE_APP_ID=abc123

Plugins are configured in _config.yml and _config-glossary.yml. Get your Contentful space id and access token using the Contentful web app. Open the space that you want to access (the top left corner lists all spaces), and navigate to the Settings > API keys. Select the API keys option and there should be an existing API key under Jekyll for Covid-19 Expert Database.

Get the AIRTABLE_API_KEY from your account on Airtable and AIRTABLE_APP_ID from the source base.

For Algolia, get the credentials from your dashboard. Set develop environment variables for index names as ALGOLIA_INDEX_NAME_QUESTIONS=covid19_dev and ALGOLIA_INDEX_NAME_GLOSSARY=covid19_glossary_dev. For production, remove the _dev from them.

And run source ~/.bashrc or open new terminal to enable changes.

  1. ./build.sh to build the site by fetching content from Contentful, Airtable and sync indeces with Algolia. We are using two jekyll config files as we are sending data to two Algolia indeces and the plugin supports a single configuration at a time.
  2. jekyll serve to serve the site at http://127.0.0.1:4000
  3. Edit .scss, .html and .js files. The browser should live-reload.

Page Generation from Contentful and Airtable Data

To generate pages in Jekyll based on Contentful and airtable data we are using the jekyll-datapage_gen plugin. Specify in _config.yml the data files for which you want individual page to be generated. See plugin’s documentation and our config.yml for the settings.

All pages are generated using the data_page_generator plugin. See config.yml for its configuration.

Deploy settings on Netlify

learnaboutcovid19.org is deployed on Netlify. Adding a website on Netlify is super easy. All these settings are under Build & Deploy section of Netlify’s web app. Here are the main steps:

  1. Select which Github repository and branch to deploy.
  2. Specify this build command: ./build.sh
  3. Set all the environment variables for contentful, airtable and algolia mentioned earlier.
  4. Add build hook for Contentful’s master and develop environment. Get the webhook urls using the Contentful web app. Open the space and navigate to the Settings > Webhooks. You will see two webhooks already setup. See their details to copy the url or adjust what triggers it. See Contentful’s Intro to webhooks to learn more.

See Continuous Deployment on Netlify docs to learn more.