lan
lanterns
npm i lanterns
lan

lanterns

⛩Write Markdown and get a GraphQL API for querying them for free

by Vadim Demedes

1.1.0 (see all)License:MITTypeScript:Not Found
npm i lanterns
Readme


Lanterns


Lanterns Build Status

Write Markdown and get a GraphQL API for querying them for free

Deploy to now

Install

$ npm install --global lanterns

Usage

Create a folder for storing your Markdown files and name it documents:

mkdir documents

Create a file and name it according to [year]-[month]-[day]-[slug] format, then write the contents:

---
title: Hello World
category: News
---

This is my first post!

Run Lanterns:

$ lanterns
❯ Server is listening at port 3000

Execute GraphQL queries at http://localhost:3000/graphql:

{
    query {
        documents {
            title
            slug
            category
            body
        }
    }
}

Schema

Document

Document represents a single Markdown file in the file system.

type Document {
    # Title extracted from frontmatter's `title`
    title: String!
    # Title converted to a slug
    slug: String!
    # Category extracted from frontmatter's `category`
    category: String
    # All frontmatter fields
    frontmatter: JSON!
    # Document body without frontmatter
    body: String!
    # Date when a document was created
    createdAt: Date!
    # Date when a document was last updated
    updatedAt: Date!
}

documents(skip: Int, limit: Int)

Query documents with optional pagination parameters skip and limit.

Example:

{
    query {
        documents {
            title
            slug
            category
            frontmatter
            body
            createdAt
            updatedAt
        }
    }
}

document(slug: String!)

Query a single document by its slug.

Example:

{
    query {
        document(slug: "hello-world") {
            title
            slug
            category
            frontmatter
            body
            createdAt
            updatedAt
        }
    }
}

categories

Query all categories. This resolver scans all documents looking for category field in frontmatter, removes duplicates and returns the list.

License

MIT © Vadim Demedes

Downloads/wk

3

GitHub Stars

353

LAST COMMIT

5yrs ago

MAINTAINERS

1

CONTRIBUTORS

1

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
1.1.0
latest
5yrs ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate