digitalinteraction / deconf-api-toolkit

A library for running decentralised virtual conferences
https://deconf-api.openlab.dev/
MIT License
2 stars 0 forks source link

Add markdown content APIs from PlanetRed #14

Closed robb-j closed 2 years ago

robb-j commented 2 years ago

PlanetRed had a /content/:slug API which returned localised html generated from markdown in the planetred-content repo. This would be a useful addition to the framework. It would be made up of these additions:

ContentService

A service for fetching markdown from a git repo.

The PlanetRed implementation cloned the repository into a temporary directory and used the fs API to pull out content and JSON files. The file structure looked like this:

.
├── README.md
├── content
│   ├── about
│   │   ├── ar.md
│   │   ├── en.md
│   │   ├── es.md
│   │   └── fr.md
│   ├── atrium-active
│   │   ├── ar.md
│   │   ├── en.md
│   │   ├── es.md
│   │   └── fr.md
│   ├── ...
│   ├── interpreters.json
│   └── settings.json

It used remark to process the markdown into HTML and replaced any custom components to identified div elements. e.g. %some_tag% was converted to <div id="some_tag"></div>.

Considerations

PlanetRed was explicit about which markdown slugs to process and would fail if parts were missing, this should be kept so from an observability perspective it is easier to detect invalid content-repo configurations.

It also parsed interpreters.json and settings.json, validated their structure and put those into redis. This shouldn't be included in the library but it should expose functionality to allow library clients to implement this themselves.

PlanetRed allowed a reuse option to use an existing directory and git pull instead of cloning into a fresh temporary directory. Which was to speed up pulls during development, it could also be used in production with a PVC or similar.

The parameters should be a git remote and branch to pull from, this allows multiple deployments to be run from the same content repository.

ContentRoutes

Provides a route to serve the relevant generated html based on the slug of the folder, i.e. /content/:slug where slug is the filename of the original markdown (without the extension). This route returned a JSON object with the processed HTML for each language.

It could take a locale parameter to only retrieve the content for a specific language if it is required for performance reasons.

robb-j commented 2 years ago

Released in 4.1.0