This package has been deprecated

Author message:

DEPRECATED, hof-middleware-markdown is built into hof v19 <(^_^)> & should not be installed separately

hof-middleware-markdown

2.0.0 • Public • Published

hof-middleware-markdown

i18n-compatible markdown rendering for static content into templates

Usage

First, mount the middleware in your app.

const markdown = require('hof-middleware-markdown');
app.use(markdown());

Then you can embed static markdown snippets in your templates as follows.

{{#markdown}}file-name{{//markdown}}

Snippets will be loaded from within content directories inside your express views directories. So if you have your express views set to /path/to/my/views then the markdown snippets will be looked for in /path/to/my/views/content.

i18n

If req.lang is set (and it will be in hof-bootstrap apps) then content will be loaded first in directories corresponding to the request langauge.

So if req.lang is set to ['en-US', 'en'] then the content will be loaded first from /path/to/my/views/content/en-us then /path/to/my/views/content/en and finally /path/to/my/views/content.

Note: language codes are always lower case when mapped to directories.

Configuration

The markdown middleware can be configured by passing options at initialisation.

const markdown = require('hof-middleware-markdown');
app.use(markdown(options));

Options

  • method - Default: markdown - sets the name of the method exposed to templates.
  • ext - Default: md - sets the file extension of content files.
  • dir - Default: content - sets the subdirectory of views in which to find content snippets.
  • fallbackLang - Default: [''] - sets the directories in which to look for content if no matching language specific directory exists.

/hof-middleware-markdown/

    Package Sidebar

    Install

    npm i hof-middleware-markdown

    Weekly Downloads

    1

    Version

    2.0.0

    License

    MIT

    Last publish

    Collaborators

    • temitopeayoku
    • mdev246
    • vinodha.s
    • chisomoguibe
    • robertmccann
    • rhyad-zergane-ho
    • rhodine
    • mohameduwais
    • lennym
    • easternbloc
    • joefitter
    • coupey
    • sulthan-ahmed
    • andrew.moody.ho
    • aswann
    • robertdeniszczyc2
    • agraham19
    • aaron.robinson
    • sarahjaneluff
    • cmedland
    • hof-bot-user