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-nuxt

v1.0.30

Published

[![npm (scoped with tag)](https://img.shields.io/npm/v/wp-nuxt.svg?style=flat-square)](https://www.npmjs.com/package/wp-nuxt) [![npm](https://img.shields.io/npm/dt/wp-nuxt.svg?style=flat-square)](https://www.npmjs.com/package/wp-nuxt) [![CircleCI](https:/

Downloads

172

Readme

wp-nuxt

npm (scoped with tag) npm CircleCI Codecov Dependencies js-standard-style FOSSA Status Netlify Status

📖 Release Notes

Features

The module adds WP-API to your nuxt application.

The size of the library is 49,8 kB minified (14 kB gzipped). npm bundle size

Setup

  • Add wp-nuxt dependency using yarn or npm to your project

  • Add wp-nuxt to modules section of nuxt.config.js

{
  modules: [
    // Simple usage
    'wp-nuxt',

    // With options
    ['wp-nuxt', {
      endpoint: 'https://wp.kmr.io/wp-json',
      extensions: true // For additional functions of wpapi-extensions
      /* other options of WP-API */
    }],
 ]
}

Info: when you pass extensions: true you will have additional functions of wpapi-extensions available. For this you also have to install WUXT Headless WordPress API Extensions on your wordpress sever.

Usage

You can use the API of WP-API using the injected 'app.$wp'. (s. example)

Example

<script>
export default {
  async asyncData ({ app, store, params }) {
    return { articles: await app.$wp.posts().perPage(10) }
  }
}
</script>

Basic RSS feed integration

To use an automatically generated rss feed under /feed.xml you have to add following to your the nuxt.config.js. It will automatically fetch the posts from your rest endpoint provided in the options. (demo)

const wpNuxtFeed = require('wp-nuxt/lib/rss')

module.exports = {
  feed: [
    wpNuxtFeed({
      baseUrl: 'http://localhost:3000'
    })
  ]
}

To prevent injecting the default link tag into the head you can pass the option injectDefaultHead: false. Any options such as title or description can be overwritten through the function options. For more options look into the feed module and the definition of th function.

Basic sitemap integration

Using the module nuxtjs/sitemap a opinionated sitemap is provided by default.

Specific options can be overwritten like the following in the nuxt.config.js:

module.exports = {
  wp: {
    sitemap: {
      hostname: process.env.HOSTNAME // default; format e.g. 'http://localhost:3000'
    }
  }
}

It can be completely overwritten using the sitemap property in the nuxt.config.js and deactivated using following:

module.exports = {
  wp: {
    sitemap: false
  }
}

See more options in the extension nuxtjs/sitemap or in the following file

Custom Routes

You can register your own routes e.g. for custom extentions.

module.exports = {
  wp: {
    endpoint: 'https://wp.kmr.io/wp-json',
    customRoutes: [
      {
        extension: 'wp/v2',
        route: 'custom-taxonomy',
        name: 'customTaxonomy'
      }
    ]
  }
}

This will call wp.customTaxonomy = wp.registerRoute('wp/v2','custom-taxonomy' and make it available as app.$wp.customTaxonomy()

Auto-Discovery

For more infos: https://github.com/WP-API/node-wpapi/tree/master#auto-discovery

module.exports = {
  wp: {
    endpoint: 'https://wp.kmr.io/wp-json',
    discover: true // To auto-discover routes by url provided in 'endpoint'
  }
}

Info: Make sure to handle CORS correctly. s. https://github.com/WP-API/node-wpapi/tree/master#cross-origin-auto-discovery

Browser Support

IE11 seems to work, but throws errors. (Help wanted)

License

MIT License

Copyright (c) yashha

FOSSA Status