mirror of https://github.com/tinyhttp/markdown.git
v1rtl 2f059d045a | ||
---|---|---|
.github | ||
.husky | ||
src | ||
tests | ||
.eslintignore | ||
.eslintrc | ||
.gitignore | ||
.prettierignore | ||
.prettierrc | ||
LICENSE | ||
README.md | ||
commitlint.config.cjs | ||
package.json | ||
pnpm-lock.yaml | ||
rollup.config.js | ||
tsconfig.json |
README.md
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 pathsstripExtension
- remove.md
(or.markdown
) extension from markdown files. Enabled by defaults.markedOptions
- initial marked options to be used by the handler.caching
settings forCache-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)