🗒 Static markdown middleware for Node.js.
Go to file
v1rtl 2f059d045a
Update FUNDING.yml
2023-10-26 16:05:13 +00:00
.github Update FUNDING.yml 2023-10-26 16:05:13 +00:00
.husky tooling: husky 2021-09-18 11:55:34 +03:00
src feat: better types 2021-09-24 10:02:39 +03:00
tests feat: move markdown to a separate library 2021-07-10 18:38:00 +03:00
.eslintignore Initial commit 2021-07-10 18:21:27 +03:00
.eslintrc Initial commit 2021-07-10 18:21:27 +03:00
.gitignore Initial commit 2021-07-10 18:21:27 +03:00
.prettierignore Initial commit 2021-07-10 18:21:27 +03:00
.prettierrc Initial commit 2021-07-10 18:21:27 +03:00
LICENSE Initial commit 2021-07-10 18:21:27 +03:00
README.md Update README.md 2023-05-27 14:41:22 -04:00
commitlint.config.cjs Initial commit 2021-07-10 18:21:27 +03:00
package.json 2.0.4 2021-09-24 10:03:37 +03:00
pnpm-lock.yaml feat: better types 2021-09-24 10:02:39 +03:00
rollup.config.js Initial commit 2021-07-10 18:21:27 +03:00
tsconfig.json feat: better types 2021-09-24 10:02:39 +03:00

README.md

@tinyhttp/markdown

npm GitHub Workflow Status Coverage

Static markdown middleware for Node.js.

Install

pnpm i @tinyhttp/markdown

API

markdownStaticHandler(dir, options)

Handles static files and transforms markdown in HTML in a specified directory. It tries to assign root to README.md or index.md (and with .markdown extension too) in case any of them exists.

Options

  • prefix - URL prefix to add to routes and remove from file paths
  • stripExtension - remove .md (or .markdown) extension from markdown files. Enabled by defaults.
  • markedOptions - initial marked options to be used by the handler.
  • caching settings for Cache-Control header. Disabled by default.

Example

import { App } from '@tinyhttp/app'
import { markdownStaticHandler as md } from '@tinyhttp/markdown'

new App()
  .use(
    md('docs', {
      prefix: '/docs',
      stripExtension: true,
      markedExtensions: [{ headerIds: true }]
    })
  )
  .listen(3000)