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

wp-react-stories

v0.1.2

Published

A React-based, masonry-like display of categorized posts drawn from the WordPress REST API.

Downloads

9

Readme

wp-react-stories

A masonry-like display of posts from the WordPress REST API. Includes search and a category select input.

Demo.

Install

Composer/WordPress

If you plan to use the WordPress shortcode, this library can be installed via Composer or activated as a WordPress plugin. To install via Composer, use:

composer require colbycomms/wp-react-stories

Note the WordPress parts of this plugin require PHP 7.1 or higher.

From NPM

If you're not using the shortcode and plan to import this library into your ES6, Javascript, install it with npm:

npm install wp-react-stories

Or:

yarn add wp-react-stories

Usage

In ES6 Javascript

First, if you installed this library using Composer and plan to import the component into your Javascript, you need to prevent the plugin's compiled script from enqueuing. In your WordPress project, add the following filter:

add_filter( 'colbycomms__stories__enqueue_script', '__return_false' );

Include the Stories component in your project, e.g.:

import React from 'react';
import ReactDOM from 'react';
import Stories from 'wp-react-stories';

const myContainer = document.querySelector('#my-container-element');
const myProps = {
    // See below.
}

ReactDOM.render(<Stories {...myProps} />, myContainer);

Props

endpoint {string} required

The WordPress REST endpoint from which to draw posts, e.g. http://your-site.com/wp-json/wp/v2/posts/. Custom endpoints must support the parameters search, page, categories, and per_page.

categoriesEndpoint {string} required

The WordPress REST endpoint from which to draw categories, e.g. http://your-site.com/wp-json/wp/v2/categories/.

mediaEndpoint {string} required

The WordPress REST endpoint from which to draw media, e.g. http://your-site.com/wp-json/wp/v2/media/.

perPage {string} default = 12

A numeric string for the number of posts to show per page.

In WordPress

To use this plugin out of the box without any ES6 inclusion, simply install it with Composer or activate it as a plugin, then use this shortcode:

[stories endpoint="http://my-site.com/wp-json/wp-v2/posts/"]

All the shortcode attributes have defaults (see below), so simply use [stories] if all the defaults apply.

Shortcode attributes

endpoint default = get_bloginfo( 'url' ) . '/wp-json/wp/v2/posts/'

The WordPress REST endpoint from which to draw posts.

categories-endpoint default = get_bloginfo( 'url' ) . '/wp-json/wp/v2/categories/'

The WordPress REST endpoint from which to draw categories.

media-endpoint default = get_bloginfo( 'url' ) . '/wp-json/wp/v2/media/'

The WordPress REST endpoint from which to draw media files.

per-page default = '12'

The number of posts to show per page.