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

markdown-handler

v0.3.8

Published

Markdown Handler - Mini utility to help you load your markdown files on the fly

Downloads

17

Readme

Markdown Handler

Build Status NPM version Dependencies Coverage Status

Mini utility to help you load your markdown files by using the paths to .md files.

Latest Update

0.33

  • added function parseContent to parse individual markdown files.

Features

  • Reads markdown contents by using the paths without pre-build.
  • Provides some basic meta data such as tags, categories, date, coverimage but it is flexible to configure.

Installation

Node.js

npm install markdown-handler

Usage Example (ES6)

import MarkdownHandler from 'markdown-handler';

let mdHandler = new MarkdownHandler();

var paths = [
        "https://sporule.com/1.md",
        "https://sporule.com/2.md",
        "https://sporule.com/3.md"
]

mdHandler.loadMds(paths).then(posts => {
          console.log(posts);
});

One of the example markdown files


---
title: "This is another Demo Post" 
author: "Sporule"
date: "2019-09-10"
categories: "Another Demo"
tags: "tagA,tagD"
coverImage: "https://i.imgur.com/GzmpA4s.png"
---

# Paragraph 1
Lorem ipsum dolor sit amet, nullam putent deserunt mel no, cum periculis intellegebat ne. Noluisse voluptatibus id sed, iudico essent ius et. In mutat mucius probatus eum. Has cu iusto audiam quaeque. Ad idque essent mei.

Mel solet aperiri similique id, ei mutat essent cotidieque eam, tempor ancillae pri te. Est at utroque explicari, eam comprehensam mediocritatem eu. Duis quodsi commune id cum, et eum noluisse consequuntur. Tation nullam conclusionemque mel in, nec volutpat splendide ad, nec ne persecuti intellegebat. Sed antiopam maiestatis rationibus no. Vocibus appetere mea an, no vix habeo dicant probatus.

Output structure

posts:
  {
    "items": [
      {
        "title": "",
        "content": "",
        "excerpt": "",
        "path": "",
        "metas": {
          "categories": [],
          "tags": [],
          "title": "",
          "date": "",
          "coverimage": ""
        }
      }
    ]
  }

Configurations

| Variable | Default | Type | Note | | ----------------- | ----------------------------------------------------------------- | ------------ | -------------------------------------------------------------------------------------- | | excerptLength | 30 | integer | The length of excerpt, excerpt will be generated from the markdown files | | defaultThumbnail | https://i.imgur.com/GzmpA4s.png | string | The default thumbnail if there is no image in markdown file | | mustHaveMetas | ["title", "categories", "tags", "date"] | string array | This are the must have metas at the beginning of the markdown file | | excerptParser | take the set length from the markdown file | function | Input is the markdown file and the length of the excerpt, output is the excerpt string | | thumbnailParser | take the first image from markdown file as thumbnail | function | Input is the markdown file, output is the thumbnail string |

Meta Data

All meta data between at the beginning of the document will be loaded into the item object, for example if you want the color attribute in meta data, you shoud have the markdown files look like:


---
title: "This is another Demo Post" 
author: "Sporule"
date: "2019-09-10"
categories: "Another Demo"
tags: "tagA,tagD"
coverImage: "https://i.imgur.com/GzmpA4s.png"
color:"pink"
---

# Paragraph 1
Lorem ipsum dolor sit amet, nullam putent deserunt mel no, cum periculis intellegebat ne. Noluisse voluptatibus id sed, iudico essent ius et. In mutat mucius probatus eum. Has cu iusto audiam quaeque. Ad idque essent mei.

Mel solet aperiri similique id, ei mutat essent cotidieque eam, tempor ancillae pri te. Est at utroque explicari, eam comprehensam mediocritatem eu. Duis quodsi commune id cum, et eum noluisse consequuntur. Tation nullam conclusionemque mel in, nec volutpat splendide ad, nec ne persecuti intellegebat. Sed antiopam maiestatis rationibus no. Vocibus appetere mea an, no vix habeo dicant probatus.

Example Implementation of the Code

Sporule : A micro blog system that uses markdown-handler