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

@dodiameer/md2pages

v1.0.2

Published

A basic SSG that turns Markdown to HTML pages

Downloads

11

Readme

md2pages

A basic SSG that turns Markdown to HTML pages. It uses md2html, another package I made that wraps around remark and gray-matter, to generate HTML, and then replaces placeholders in a template with the generated HTML and (optional) YAML front-matter data.

Usage

Usage is very simple, as currently it only has one function. Once more functionality is added, there will be a documentation page.

Javascript

const md2pages = require("@dodiameer/md2pages");
const fs = require("fs");
/* HTML Template Can be a multiline string with backticks (`...`)
 * or an output of fs.readFile() (or fs.readFileSync). I.E as long
 * as you pass a string it should be okay
 */
const htmlTemplate = fs.readFileSync("path/to/template.html"); // Or a multiline string  
md2pages.generateHTML(inputDirectory, outputDirectory, {
    htmlTemplate: htmlTemplate
});

If no template is provided, it will default to a simple template with the content inside an <article/>.

HTML template

<html>
    <head>
        <!-- Anything inside {curly brackets} is considered YAML front-matter data -->
        <title>{title}</title>
        <!-- Here, {title} will be replaced with the title defined in YAML front-matter -->
    </head>
    <body>
        <article>
            <h1>{title}</h1>
            <h2>Author: {author}</h2>
            {{html}}
            <!-- 
                {{html}} is where the generated HTML will be placed. If omitted, generated HTML will not be output. NOTE: this is the only tag with double curly brackets
            -->
        </article>
    </body>
</html>

Note: currently, YAMl front-matter support only works with strings and numbers, meaning you can't use lists or objects. However, there are plans to support this in the near future.

Contributors

  • dodiameer (Me)

Note that currently, I'm the only one working on this and I'm just a hobbyist with no work experience. Some code will run badly and have unexpected bugs (features?). I don't recommend using this in a project other than a simple project or a project where you don't mind messy code in your libraries, until I either have proper knowledge or someone with me to give me some guidance. If you do decide to use this or even just give it a try, please tell me what you think. Your advice is priceless and will always be welcome.

Thanks for reading ^__^.