Socket
Book a DemoInstallSign in
Socket

post-type-discovery

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

post-type-discovery

A Javascript implementation of the [Post Type Discovery](https://www.w3.org/TR/post-type-discovery/) W3C spec.

1.0.4
latest
Source
npmnpm
Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 06 Jun 2020

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.