fetch-to-markdown
v1.3.3
Published
Fetch markdown content from api and write to files with frontmatter and component appending support
Downloads
39
Readme
Fetch to Markdown
Fetch markdown content from api and write to files with frontmatter and component appending support.
Table of Contents
About The Project
Fetch to Markdown solves a common problem when working with a headless CMS by simply fetching your content at a provided api endpoint and writing to markdown files. It supports writing custom frontmatter and appending component tags to each file.
☕️ Usage
Usage is simple and assumes a REST api endpoint.
First install the module
npm install fetch-to-markdown
yarn add fetch-to-markdown
Download from a single resource
const { fetchToMarkdown } = require('fetch-to-markdown')
fetchToMarkdown('https://www.cms-backend.com', 'articles' {
contentDir: 'public' // the directory to write files relative to project root (defaults to 'content')
}),
Or from multiple resources at once
const { fetchToMarkdown } = require('fetch-to-markdown')
const contentAPI = 'https://www.cms-backend.com'
Promise.all([
fetchToMarkdown(contentAPI, 'articles', {
components: articleComponents,
}),
fetchToMarkdown(contentAPI, 'projects', {
readme: `Write a custom README.md file in the /projects directory`,
}),
fetchToMarkdown(contentAPI, 'companies'),
fetchToMarkdown(contentAPI, 'links'),
fetchToMarkdown(contentAPI, 'about'),
fetchToMarkdown(contentAPI, 'landing', {
components: landingComponents,
landing: true // writes file
}),
])
🤝 Contributing
Want to make a change? Any contributions you make are greatly appreciated.
Check out the issues page
🗺 Roadmap
See the open issues for a list of proposed features (and known issues)