post-type-discovery

Implementation of post type discovery W3C spec

Showing:

Popularity

Downloads/wk

7

GitHub Stars

4

Maintenance

Last Commit

1yr ago

Contributors

3

Package

Dependencies

21

Size (min+gzip)

74.0KB

License

BSD-3-Clause

Type Definitions

Tree-Shakeable

No?

Categories

Readme

post-type-discovery

A Javascript implementation of the Post Type Discovery W3C spec.

Build Status Coverage Status Inline docs devDependencies Status dependencies Status

Installation

Use npm to install:

npm install post-type-discovery --save

Usage

The library exposes just one method that tells you the type of a post given a parsed microformats JSON.

var getType = require( 'post-type-discovery' );

// You can get parsed mf2 using a library like microformat-shiv, or microformat-node
var mf2 = {"items":[{"type":["h-entry"],"properties":{"author":[{"type":["h-card"],"properties":{"name":["Tantek \u00c7elik"],"photo":["http://tantek.com/logo.jpg"],"url":["http://tantek.com/"]},"value":"Tantek \u00c7elik"}],"name":["\ud83d\udcd5 started reading \u201cThe Eight Limbs of Yoga\u201d by Stuart Ray Sarbacker and Kevin Kimple. tantek.com/isbn/086547768X #yoga"],"category":["yoga"],"url":["http://tantek.com/2017/200/t1/started-eight-limbs-of-yoga"],"uid":["http://tantek.com/2017/200/t1/started-eight-limbs-of-yoga"],"syndication":["https://twitter.com/t/status/887903244676214784"],"published":["2017-07-19T22:08-0700"],"updated":["2017-07-19T22:08-0700"],"content":[{"html":"\ud83d\udcd5 started reading \u201cThe Eight Limbs of Yoga\u201d by Stuart Ray Sarbacker and Kevin Kimple. <a class=\"auto-link\" href=\"http://tantek.com/isbn/086547768X\">tantek.com/isbn/086547768X</a> #<span class=\"p-category auto-tag\">yoga</span>","value":"\ud83d\udcd5 started reading \u201cThe Eight Limbs of Yoga\u201d by Stuart Ray Sarbacker and Kevin Kimple. tantek.com/isbn/086547768X #yoga"}]}}]};

// Get the post type
var type = getType( mf2 );

The code is small, easy to read, and documented.

Contributing

Feel free to send pull requests, add test cases, and raise issues. To setup a development environment clone the repo and install dependencies.

$ npm install

# Lint, hint, and run tests
$ npm test

# Run just the tests while developing
$ npm run jest -- --watch

# Build the docs
$ npm run docs

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100