Skip to content

Hamatti/eleventy-netlify-functions-demo

Repository files navigation

Demo: 11ty Global Data & Netlify Functions

A demo repository for a blog post Providing next event as API with Eleventy’s Global Data Files and Netlify Functions.

This repository contains an Eleventy project that uses Netlify Functions for API access to global data.

In _data/, we have events.json with a few past and upcoming events. When we build the project, we create a Netlify Function (a serverless function) that returns that next event (or a different response if no events are scheduled for the future).

To run

First, you need to install the dependencies

npm install

and install global Netlify CLI

npm install -g netlify-cli

Then run

netlify dev

to start a local development server that can run Netlify Functions.

API Docs

Once running, you can call domain:8888/.netlify/functions/api which will return either

Next scheduled event exists

{
  "status": "OK",
  "data": { "date": "2025-05-20", "name": "May" }
}

where "status" is always "OK". Event data has date in format YYYY-MM-DD and name.

No scheduled future events exist

{
  "status": "NO_EVENT_SCHEDULED",
  "data": null
}

If no future events exist, "status" will be "NO_EVENT_SCHEDULED" and "data" will be null.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published