The file system client for Dimer offers the API to convert the docs into a tree of versions and docs content

Downloads in past


2.0.14 years ago4 years agoMinified + gzip package size for @dimerapp/fs-client in KB


<img width="500" src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1532274184/Dimer_Readme_Banner_lyy7wv.svg" alt="Dimer App">

<a href="https://dimerapp.com/what-is-dimer">
  Dimer is an open source project and CMS to help you publish your documentation online.

<sub>We believe every project/product is incomplete without documentation. <br /> We want to help you publish user facing documentation, without worrying <code>about tools or code</code> to write.</sub>

Dimer FsClient
The file system client for Dimer offers the API to convert the docs into a tree of versions and docs content. Later you can use this with the combination of datastore to store it with the database.


npm i @dimerapp/fs-client

# yarn
yarn add @dimerapp/fs-client


const FsClient = require('@dimerapp/fs-client')
const ConfigParser = require('@dimerapp/config-parser')
const Context = require('@dimerapp/context')

const basePath = process.cwd()
const ctx = new Context(basePath)

const { errors, config } = await (new (new ConfigParser(ctx))).parse()

const client = new FsClient(ctx, config.zones)
const tree = await client.tree()

You can pass markdownOptions to dfile by setting them on the ctx.
ctx.set('lib-name', 'markdownOptions', {
  async onUrl () {

Allowed files

The files must have .md, .markdown, .mkd and .mkdown extensions, otherwise they will be ignored.

Watch for changes

client.watch(async (event, arg) => {
  if (event === 'add:doc' || event === 'change:doc') {

  if (event === 'unlink:doc') {

  if (event === 'unlink:version') {
    console.log('removed directory for a given version')

  if (event === 'change:config' || event === 'add:config') {
    console.log('config file changed')

  if (event === 'unlink:config') {
    console.log('config file removed, stop watcher')

Fs client API

Following is the API for the watcher.


const FsClient = require('@dimerapp/fs-client')
const client = new FsClient(ctx, zones)

// or with markdown options
ctx.set('markdownOptions', {
const client = new FsClient(ctx, zones)


Returns an array of files path tree for all the versions. Only files ending with .md and .markdown are picked.
const tree = await client.filesTree()


Returns a content tree of all the files mapped with their versions.
const tree = await client.tree()


Watch for changes in the docs or the config file. dimer.json.
client.watch(() => {

watchVersion(zoneSlug, version)

Tell watcher to start watching a new version when it is added to the config file.
client.watchVersion('guides', {
  no: '1.0.0',
  location: 'docs/1.0.0'

unwatchVersion(zoneSlug, location)

Tell watcher to stop watching files for a given version, when it is removed from the config file.
client.unwatchVersion('guides', docs/master')

!travis-imagetravis-url !npm-imagenpm-url


Following is the list of events and data associated with them.
The versions inside the events will have additional property called zoneSlug attached on them. You can use that
property to add data to the datastore.
| Event | Data | Description | |-------|------|-------------| | add:doc | { versions: [], file } | Data includes an array of versions and the Dfile object for that given file. | | change:doc | { versions: [], file } | Data includes an array of versions and the Dfile object for that given file. | | unlink:doc | { versions: [], baseName } | Data includes an array of versions and baseName of the file that was removed. | | unlink:version | [{ no: '1.0.0' }] | Data includes an array of versions that shares the directory which was removed. | | add:config | undefined | Config file created | | change:config | undefined | Config file changed | | unlink:config | undefined | Config file removed | | error | Error | There was an error |

Change log

The change log can be found in the CHANGELOG.md file.


Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.

Authors & License

thetutlage and contributors.
MIT License, see the included MIT file.