Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kodex

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kodex

a simple library for sorting and filtering through a directory of front-matter parsed markdown files

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Kodex

Kodex walks a directory of markdown files, parses them as front-matter, and generates a simple API for accessing those files.

The main focus is to provide sorting and filtering methods for (but not limited to) blog posts. The service can be used in any number of ways. Wrap a RESTful API around it, or utilize it during static generation (plays nicely with Nuxt.js).

Features:

  • Recursively walks through a given directory
  • Parses all markdown (.md) files with front-matter
  • Generates a service for acquiring data from the collection

Planned:

  • Pluggable support for other markup languages
  • Custom attributes
  • Sorting and filtering by custom attributes

File Format

./posts/hello-world.md:

---
title: Hello, world!
date: 4/20/2017
tags: [javascript, kodex.js]
---

This is an example markdown.

Currently, the date attribute is the only required front-matter attribute. title and tags are optional attributes.


Usage

let Kodex = require('kodex')
let postKodex = new Kodex(path.join(__dirname, 'posts'))

var helloWorldEntry = postKodex.get('hello-world')

Docs

.get(filename)

Gets an entry by filename

Returns: Object

.search(term)

Searches for files where filename contains term

Returns: Array

.recent(count)

Gets n most recent entries (sorted by date descending)

Returns: Array

.allTags()

Scrapes all tags from files

Returns: Array

.findWithTag(tagName)

Gets all files that have the specified tag

Returns: Array


Caveats:

  • Directory cannot contain extensionless files (matches folders based on lack of period, confuses for folder)

FAQs

Package last updated on 11 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc