All Projects → hackclub → markdown

hackclub / markdown

Licence: MIT license
Render Markdown to HTML, Hack Club-style

Programming Languages

javascript
184084 projects - #8 most used programming language

@hackclub/markdown

Render Markdown to HTML, Hack Club-style. Used primarily on the Hack Club Workshops site.

yarn add @hackclub/markdown
# npm i @hackclub/markdown

Try the demo

Usage

This package does not include any frontend code, such as React or CSS.

This package is designed for rendering at build or otherwise on a server, not client-side— the bundle size is significant & it’s not been optimized for performance.

Always use with await.

import fs from 'fs'
import md from '@hackclub/markdown'

const getReadme = async () => (
  const text = fs.readFileSync('./README.md', 'utf8')
  return await md(text, '/README.md', '/static')
)
Param Default Description
input Req’d! String. The Markdown text to transform.
filePath '/README.md' String. The Markdown’s path (for fixing relative image links).
imagePrefix '/' String. A prefix for the path to relative images.
removeTitle false Bool. Remove starting h1 (if titles are rendered separately).

If you need to parse frontmatter, we recommend using gray-matter alongside @hackclub/markdown, but it’s not included in this package.


Partially based on the Next.js documentation site.

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].