avitorio / outstatic

Outstatic - A static CMS for Next.js

Home Page:https://Outstatic.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Metadata DB

jakobo opened this issue · comments

Discussion: #53

Why

Right now, there are several "query"-like operations difficult to do in outstatic. Some examples:

  • "get all documents, sorted by their publishedAt value"
  • "get the first 5 documents in the posts collection, written by the user Jim"
  • "get all the documents, across all the collections"

It would be unreasonable in even a moderate site (20 pieces of content) to do an FS read on every file, YAML parse the frontmatter, and then perform operations on the merged set of frontmatter data.

Proposed Solution

This issue is tracking the work on a Metadata DB; a file updated on edit/delete and via SWR which contains the most recent copy of metadata from every piece of outstatic content's frontmatter.

  • The sync is unidirectional (files -> metadata db) and dirty data is acceptable, returning cached values
  • A new metadata DB results in a new deployment, which allows getStaticProps / getServerSideProps to refresh their queries