Skip to content

Latest commit

 

History

History
138 lines (117 loc) · 4.48 KB

README.md

File metadata and controls

138 lines (117 loc) · 4.48 KB

Contented

Contented is a prose bundler for your documentation with pipeline driven authoring-oriented workflow to encourage developers authoring within its contextual Git repository.

With a headless design of 1 config file contented.config.mjs, developers can start writing their markdown content and preview it on their localhost contented generate --watch. Choosing convention over configuration reduces HTML/UI clutter, allowing developers to focus on authoring.

Authored content can be continuously delivered (CD) into a hosted static site (e.g., GitHub Pages/Netlify/Vercel) for preview contented generate. As code drift, so does documentation; this allows each pull request to have an accompanying sharable preview of the documentation. With CD, it effectively shift-left your documentation workflow and checks it is compilable and presentable.

By encouraging authoring next to the source (in the same git repo), developers can contextually document changes as they develop. All domain-specific changes will go into the main branch with one Git Pull Request.

With contented build, you can compile your prose into sources index.js and *.json. That output into ./dist to npm publish them into any registry of your choice, for you can easily npm i @your-scope/your-npm-package and use the processed content on any of your downstream sites. Easily pulling up-to-date content and prose from individual domain-specific repositories and re-presented. Think microservices, but for your prose!

Motivation

If you don’t make it easy to get something done (authoring), nobody will go out of their way to get it done perfectly every time. Turn it into a GitOps workflow and give people the necessary tools and power to get it done perfectly every single time — everyone will get it done, as now there is no other way else to get it done. An efficient workflow naturally satisfies.

Just Another SSG?

This is not a static site generator. This is a prose processor workflow with a built-in static site generator. The outcome we're trying to achieve is this @contentedjs/contented-example/dist

See Contented Limitations

Powered By

Getting Started

Your docs can be anywhere as long as contented is configured to pick them up.

repo/
├─ packages/**
├─ docs/
│  ├─ 01-Title 1/*.md
│  ├─ 02-Title 2/*.md
│  ├─ 03-Title 3/
│  │  ├─ 01-Subtitle 1/*.md
│  │  ├─ 02-overview.md
│  │  └─ 03-faq.md
│  └─ package.json
├─ contented.config.mjs
├─ package.json
└─ README.md

package.json

{
  "name": "@contentedjs/contented-example",
  "version": "0.0.0",
  "private": false,
  "files": ["dist"],
  "main": "dist/index.js",
  "scripts": {
    "write": "contented generate --watch",
    "generate": "contented generate",
    "build": "contented build"
  },
  "devDependencies": {
    "@contentedjs/contented": "latest"
  }
}

contented.config.mjs

/** @type {import('@contentedjs/contented').ContentedConfig} */
export default {
  preview: {
    url: 'https://contented.fuxing.dev',
    name: 'Contented',
    github: {
      url: 'https://github.com/fuxingloh/contented',
    },
  },
  processor: {
    pipelines: [
      {
        type: 'Docs',
        pattern: 'docs/**/*.md',
        processor: 'md',
        fields: {
          title: {
            type: 'string',
            required: true,
            resolve: (s) => s ?? 'Contented',
          },
          description: {
            type: 'string',
          },
          tags: {
            type: 'string[]',
          },
        },
        transform: (file) => {
          file.path = file.path.replaceAll(/^\/docs\/?/g, '/');
          file.sections = file.sections.slice(1);
          return file;
        },
      },
    ],
  },
};

Examples