GithubHelp home page GithubHelp logo

clairechabas / google-sheets-blog Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 91 KB

๐Ÿ“‘ A Blog Using Google Sheets As Headless CMS

License: MIT License

JavaScript 6.26% TypeScript 93.74%
blog google-apis google-sheets-api headless-cms react typescript

google-sheets-blog's Introduction

๐Ÿ“‘ Blog Using Google Sheets As Headless CMS

Playing with the Google Sheets API to serve as database for a blog. This repo is free to use and can be used as a starter for a project using the Google Sheets API.


Getting Started

  1. Clone this repo
  2. Install dependencies
npm install
# or
yarn install
# or
pnpm install
  1. Create a .env.local file for your environment variables by copying the example file:
cp .env.local.example .env.local
  1. Generate your API keys JSON file in the Google Sheets API page in your Google Cloud Console. Place that JSON file where you want in your project, just make sure to had its location to you .gitignore so it doesn't get committed. Finally, paste the location to that file as your GOOGLE_APPLICATION_CREDENTIALS environment variable's value. If you're getting serious with your project make sure to check the best practices recommended by Google on how to manage those service account keys before releasing it to production.
  2. Create a spreadsheet in your Google Drive. Add the columns you need for your project's database table. Make it available publicly with "Viewer" permission only. Copy the spreadsheet ID from the shareable URL (you obtain the URL y clicking "Copy link" in the "Share" modal). Paste that ID as your GSHEETS_FILE_ID environment variable's value.
  3. In the /src/pages/posts/[id].tsx file make sure to update the range constant with your own spreadsheet's sheet (or tab) name in place of posts if you named it differently (by default it's generaly 'Sheet1' or 'Sheet 1').
  4. Start the development server:
npm run dev
# or
yarn dev
# or
pnpm dev

Finally, open http://localhost:3000 in your browser and navigate to http://localhost:3000 to see your first row's content!


This project is using Next.js. It was bootstrapped with create-next-app and is using the Google Sheets API.


Enjoy!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.