Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
If you're creating content in markdown or use a CMS like NetlifyCMS which outputs markdown files, jdown can transform the content into JSON containing HTML at build time, ready to be consumed within templates.
$ npm install jdown --save-dev
const jdown = require('jdown');
jdown('path/to/content').then(content => console.log(content));
Call jdown with the path to your markdown content (relative to the project root) and it will convert your content to JSON.
The structure of the JSON that jdown outputs depends on how files within the content folder are structured.
Will be turned into an object, file objects will always contain a contents
and
fileInfo
property...
Will be turned into individual objects then grouped within a parent object that has the same name as the parent folder (don't go more than one level deep).
To generate arrays of file objects a folder named "collections" can be created. The collections folder should only contain sub folders, each then each file within a sub folder will be added to an array of objects.
YAML frontmatter can be included at the top of any files throughout and it will be added to the generated JSON as individual properties.
---
title: Example frontmatter
---
Example Markdown Content
Type: string
Required
Path to a folder containing markdown files with a folder structure that matches
the guidelines above. The path should be relative to the project root so if your
content was in /Users/username/project/src/content
, you would use
jdown('src/content')
.
Type: object
Type: object
Options to pass to marked, jdown supports all the available marked options which can be used to control how the markdown is parsed.
Type: object
Asset parsing options. Using jdown to parse assets is completely optional, but comes with a few benefits including:
All static assets must be placed within /assets
folders. Assets folders can be
placed in the top level content directory and/or it's sub directories. Within
the markdown content assets can then be referenced using
![](./assets/my-asset.png)
where my-asset.png
is an asset placed within an
/assets
folder.
The assets options object can contain the following properties:
Property | Type | Default | Description |
---|---|---|---|
output | string | ./public | Directory jdown will output processed assets to |
path | string | / | Publically accessible path jdown will prepend to output file names |
png | object | undefined | Options to pass into imagemin-pngquant |
jpg | object | undefined | Options to pass into imagemin-jpegtran |
svg | object | undefined | Options to pass into imagemin-svgo |
gif | object | undefined | Options to pass into imagemin-svgo |
Type: boolean
Default: true
Set this to false
to disable markdown parsing and just recieve structured JSON
containing markdown instead of HTML.
Type: boolean
Default: false
Set this to true
to include file info objects in the output JSON which contain
the files path, name, created at date and modified at date.
The example directory of this repository contains use of jdown including asset parsing and custom marked render options.
Any pull requests are welcome and will be reviewed.
MIT
FAQs
Convert a directory of markdown files to structured and usable JSON
The npm package jdown receives a total of 28 weekly downloads. As such, jdown popularity was classified as not popular.
We found that jdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.