https://github.com/seancdavis/everything-is-a-cms
Use multiple non-traditional back-ends for Next.js project. Built to support talk at Next.js Conf 2020.
https://github.com/seancdavis/everything-is-a-cms
cms jamstack nextjs talk
Last synced: about 2 months ago
JSON representation
Use multiple non-traditional back-ends for Next.js project. Built to support talk at Next.js Conf 2020.
- Host: GitHub
- URL: https://github.com/seancdavis/everything-is-a-cms
- Owner: seancdavis
- Created: 2020-10-07T11:11:20.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-10-28T10:19:37.000Z (over 4 years ago)
- Last Synced: 2025-02-25T06:39:28.586Z (about 2 months ago)
- Topics: cms, jamstack, nextjs, talk
- Language: JavaScript
- Homepage: https://youtu.be/9j9bxDf428o
- Size: 489 KB
- Stars: 66
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Everything is a CMS!
This code supports the demo from the _Everything is a CMS!_ talk from [Next.js Conf 2020](https://nextjs.org/conf/speakers/seancdavis).
Its purpose is to demonstrate that we can easily swap data sources in and out by building abstracted and normalized engines. There are two types of engines, both which are shown within this project:
- API-Based
- File-BasedCurrently, the supported data sources are:
- [Bear](https://bear.app/)
- [Contentful](https://www.contentful.com/)
- [Dropbox](https://www.dropbox.com/)
- [Fauna](https://fauna.com/)
- [Google Sheets](https://www.google.com/sheets/about/)
- [Trello](https://trello.com/)## Getting Started
_Note: This project is built to run in development mode for demo purposes. I haven't tested the build and deploy processes._
To run the project, start the Next server:
$ npm run dev
And then visit your browser at [localhost:3000](http://localhost:3000/).
See below for working with the various data engines and their drivers (i.e. sources).
### ⚠️ Environment Variables
There are a series of environment variables that are required to work with various data sources:
Data Source
Required Environment Variables
Notes
Bear
BEAR_DATABASE_PATH
Local absolute path to Bear's SQLite database.
BEAR_TAG
Notes are filtered by tag. This is the name of the tag without the#
.
Contentful
CONTENTFUL_ACCESS_TOKEN
CONTENTFUL_CONTENT_TYPE_ID
This is a word you control when creating the content type. Usually, if the type is calledSandwich
, the ID will besandwich
.
CONTENTFUL_SPACE_ID
Dropbox
DROPBOX_ACCESS_TOKEN
Create an app to generate a token.
DROPBOX_FILES_DIR
Sandwich files are filtered by directory. The path to the directory in which your files are stored should begin with a slash (e.g./everything-is-a-cms
.
Fauna
FAUNA_API_KEY
FAUNA_INDEX_NAME
The items are pulled from an index you create with Fauna. This is the name of that index.
Google Sheets
GOOGLE_CREDENTIALS
Create a service account and then a JSON key. Download the key and store it as an env var, escaping quotes and other characters as necessary.
GOOGLE_SHEET_ID
You can pull this from the URL when viewing the sheet.
Trello
TRELLO_ACCESS_TOKEN
You can find your API key and generate a token for your user here.
TRELLO_API_KEY
## API-Based Engine
The API-based engine example here is an [Apollo GraphQL server](https://www.apollographql.com/). Its contents live in the `api-engine` directory.
All drivers for this engine live in the `api-engine/lib/drivers` directory and are plugged into the `api-engine/index.js` entry file.
The server must be running to see it in action on the front-end. You can start the server by running:
$ node api-engine/index.js
You can then work with any of the API-based examples. You can also visit a playground for your GraphQL queries at [localhost:4000](http://localhost:4000/).
## File-Based Engine
The file-based engine has a reader and a writer. The reader is used by the front-end templates to read local markdown files. The writer pulls data from the data sources and writes them to markdown files in the `_data` directory.
You can import files by running the appropriate command-line script:
$ npm run import:[driver]
Supported drivers are (i.e. replace `[driver]` with one of the following):
- `bear`
- `contentful`
- `dropbox`
- `fauna`
- `sheets`
- `trello`## Questions and Feedback
If you have question regarding the implementation here or want to talk about the approach, the quickest way to get ahold of me is on Twitter: [@seancdavis29](https://twitter.com/seancdavis29).