Coder Social home page Coder Social logo

gridsome-airtable-starter's Introduction

Airtable starter for Gridsome

https://gridsomeairtable.netlify.app

Netlify Status

This starter is meant to act as a starting point/example for connecting Gridsome with Airtable.

Note: This Starter utilizes Moment.js for date/times and can be removed from the Event files if not needed (and removed with yarn remove moment)

Install Gridsome CLI tool (if you dont' have it already)

npm install --global @gridsome/cli

Create a Gridsome project

  1. gridsome create my-gridsome-site https://github.com/12vanblart/gridsome-airtable-starter.git to install this starter
  2. cd my-gridsome-site to open the folder
  3. gridsome develop to start a local dev server at http://localhost:8080
  4. Happy coding ๐ŸŽ‰๐Ÿ’ป

Configure your Airtable connection for your first table

Inside your gridsome.config.js file, you'll see the following:

// gridsome.config.js //
module.exports = {
  siteName: "Airtable Starter",
  plugins: [
    {
      use: "@gridsome/source-airtable",
      options: {
        // Add these to a .env file
        // Details on finding these values can be found at:
        // https://gridsome.org/plugins/@gridsome/source-airtable
        apiKey: process.env.AIRTABLE_KEY, //required
        baseId: process.env.AIRTABLE_BASE, //required
        tables: [
          {
            name: "Events",
            typeName: "Event", //required - needs to match template name
            select: {}, //optional
            links: [], //optional
          },
          // Comment in this section and the line in `templates` for multiple tables!
          // {
          //   name: "Parties",
          //   typeName: "Parties", //required - needs to match template name
          //   select: {}, //optional
          //   links: [], //optional
          // },
        ],
      },
    },
  ],
  templates: {
    Event: "/events/:id", //optional
    // Parties: "/parties/:id", //optional
  },
};
  • apiKey is the API secret provided by Airtable
  • baseId is the identifier for the base you would like to connect to
  • tableName is the table you would like to pull data from
  • typeName is what you would like to call your data in GraphQL
  • route is the optional path you would like to use for accessing your records. This can use GraphQL keys to identify records.

Note: In order for your templates to generate properly at the specified route a typeName.vue file must exist in \templates. In this starter, this is \templates\Event.vue for the Event type.

For connecting multiple tables or using links between tables, see the official plugin's documentation. ๐Ÿ˜„

dotenv file

Details on Gridsome Environment Variables.

You'll need to create the file .env in your root project directory (The same level as gridsome.config.js) with the following (replace with your values):

AIRTABLE_KEY=<apiKey>
AIRTABLE_BASE=<baseId>

You can learn more about getting these values from the plugin page.

NOTE: When you deploy to Netlify, you'll need to setup these values under "Build & Deploy" > "Environment" > "Environment Variables"

Query Pages

A list of files where the starter uses queries to make updating easier (all from the src folder):

  • pages/Events.vue - Grabs all Events sorted by startDate
  • components/EventCard.vue - Brings Props in from pages/Events.vue
  • templates/Event.vue - Uses id to pull in data from Airtable.

My Airtable

This is what my Airtable Base looks like:

"Airtable with columns for Name, Header Image, Start Date, End Date, Excerpt, Notes, and Attachments."

Deploy with Netlify

Deploy to Netlify

gridsome-airtable-starter's People

Contributors

uvacoder avatar

Watchers

 avatar

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.