npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

markdownbars

v1.0.10

Published

Handlebars based markdown preprocessor

Downloads

10

Readme

markdownbars

Harndlebars on the cmdline with markdown helpers.

Usage: markdownbars -i input.hbs.md [-d data] [-o output.md]

Options:
  --help, -h    Generate help                         [boolean] [default: false]
  --version     Show version number                                    [boolean]
  --input, -i   Input file                                   [string] [required]
  --output, -o  Output file                                             [string]
  --data, -d    Additional JSON data to pass into the template
                                                        [string] [default: "{}"]

install

npm install -g markdownbars

helpers

Markdownbars comes with a few convenience helpers useful for generating markdown files:

include

Usage:

{{include 'filename.tpl.md' context=obj noeval=true}}

Includes another file. You can optionally pass a context named parameter to change the context. The file will receive the data from the context as variables.

The noeval argument will disable evaluation of the file as a handlebars template - it will be included verbatim.

filetree

Usage:

{{filetree relativePath padding}}
  • relativePath - the path of the directory relative to current file
  • padding - how much to pad each item in the tree except the first one

Example:

{{filetree '.dir' 2}}

Will generate a tree list of all markdown files in 'dir'

glob

Usage:

{{#glob '*.md'}}
  The file is {{@file}}
{{glob}}

Will glob each file as specified in the glob. Double star globs are also supported. For each file found it will execute the inner block with the private variable @file containing the relative path.

The globbing is done relative to the current file's directory.

frontmatter

Usage

{{frontmatter 'filename.md' 'fieldName'}}

Reads the frontmatter of the specified file and access the desired field

basename

Usage:

{{basename filename ext}}

Acts just like node's path.basename (will strip the file directory and specified extension)

file-exists

Typical usage:

{{#if (file-exists 'relative-path')}}
  show something about this file
{{if}}

Will return true if the file exists. Typically only useful as a sub-expression.

concat

Typical Usage

{{#if (file-exists (concat @file 'OtherSegment'))}}
  some output
{{if}}

Concatenate multiple strings into one. Normally this is not needed in handlebars, however in sub-expressions it may be necessary to pass a different argument

equals

Just a regular loose equality check, useful in sub-expressions

not

Inverts a boolean, e.g.

{{#if (not (file-exists 'file'))}}
  Show content if file does not exist
{{if}}

and

Logical and, supports multiple operands

or

Logical OR, supports multiple operands

left-pad

Example Usage:

{{left-pad 2 (include 'othertemplate.md')}}

Useful to pad content produced by other helpers by the appropriate amount e.g. for lists.

cwd

Returns the current file's working directory, relative to the entrypoint file.