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

react-static-pro-plugin-sitemap

v1.10.0

Published

A react static pro plugin for exporting sitemap information

Downloads

16

Readme

react-static-pro-plugin-sitemap

A [React-Static] plugin for exporting sitemap information.

Installation

In an existing react-static site run:

$ yarn add react-static-pro-plugin-sitemap

Then add the plugin to your static.config.js:

export default {
  plugins: ['react-static-pro-plugin-sitemap'],
}

Usage

  • A config.siteRoot is required for this plugin to work properly, since sitemap's are required to use full

  • Each route in your site will createt a <url> item in the sitemap

  • By default, the url's <loc> tag will be set to the prefixed path of each route.

  • All property/value pairs under a route's sitemap object will be used as xml tags for that route, eg.

    export default {
      siteRoot: 'https://hello.com'
    }
    const routes = [
      {
        path: '/blog/post/1',
        sitemap: {
          hreflang: [
            {language:'x-default', url: '/blog/post/1'},
            {language:'en', url: '/blog/post/1'},
            {language:'de-DE', url: '/de/blog/post/1'},
          ],
          lastmod: '10/10/2010',
          priority: 0.5,
          'image:image': {
            'image:loc': `https://raw.githubusercontent.com/react-static/react-static/master/media/react-static-logo-2x.png`,
            'image:caption': 'React Static',
          },
        },
      },
      {
        path: '/blog/draft/2',
        sitemap: {
          noindex: true // Excludes route from sitemap.xml
        },
      },
    ]

    Would result in the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://hello.com/blog/post/1/</loc>
    <lastmod>10/10/2010</lastmod>
    <priority>0.5</priority>
    <image:image>
      <image:loc>https://raw.githubusercontent.com/react-static/react-static/master/media/react-static-logo-2x.png</image:loc>
      <image:caption>React Static</image:caption>
    </image:image>
    <xhtml:link rel="alternate" hreflang="x-default" href="https://hello.com/blog/post/1/" />
    <xhtml:link rel="alternate" hreflang="en" href="https://hello.com/blog/post/1/" />
    <xhtml:link rel="alternate" hreflang="de-DE" href="https://hello.com/de/blog/post/1/" />
  </url>
</urlset>

With Options

export default {
  plugins: [
    [
      'react-static-pro-plugin-sitemap',
      {
        getAttributes: route => ({
          customXmlAttribute: route.customProperty,
        }),

        // Given a route where route.customProperty === 40,
        // This would create a <customXmlAttribute></customXmlAttribute>
        // in that routes <url></url> tag
      },
    ],
  ],
}