@cheers-io/nuxt-storyblok-sitemap
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

Nuxt Storyblok sitemap

npm version npm downloads License

Generates a sitemap for content provided by Storyblok

Features

  • Dynamic sitemap generation
  • Per page filtering
  • Multilingual support

Quick Setup

  1. Add @cheers-io/nuxt-storyblok-sitemap dependency to your project
# Using npm
npm install @cheers-io/nuxt-storyblok-sitemap

# Using pnpm
pnpm add @cheers-io/nuxt-storyblok-sitemap

# Using yarn
yarn add @cheers-io/nuxt-storyblok-sitemap
  1. Add @cheers-io/nuxt-storyblok-sitemap to the modules section of nuxt.config.ts. Сonfiguration object can be passed in one of the following ways
export default defineNuxtConfig({
  modules: ["@cheers-io/nuxt-storyblok-sitemap"],
  storyblokSitemap: {
    // config object
  },
});

or

export default defineNuxtConfig({
  modules: [
    "@cheers-io/nuxt-storyblok-sitemap",
    {
      // config object
    },
  ],
});
  1. Configuration object interface
{
  // accessToken for Storyblok API
  // required
  accessToken: string;

  // base URL to be used for the sitemap generation
  // required
  baseUrl: string;

  // default locale to be used for the stories with default language
  // - if not provided, the sitemap will only contain entries for default Storyblok language
  // - if provided, the sitemap will contain entries for all Storyblok languages (if any)
  // optional, default ""
  defaultLocale: string;

  // can be used to filter out stories by full_slug via RegExp
  // optional, default []
  blacklist: string[];

  // Storyblok API url
  // optional, default "https://api.storyblok.com/v2/cdn/stories"
  apiUrl: string;

  // path to the sitemap file, relative to the website domain
  // optional, default "sitemap.xml"
  uri: string;
}

That's it! You can now use Nuxt Storyblok sitemap in your Nuxt app ✨

Blacklist details

There is a chance you want to hide some pages from the generated sitemap. For example, you don't want to include stories that start with global/*. Or you want to hide any story which slug includes hidden part. Or maybe you don't want to see stories which end with /private word. In this case your config might look like this:

{
  blacklist: ["^global/", "hidden", "/private$"];
}

Development

# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release

Contact

Follow us on Twitter, LinkedIn or visit our website. You can also write us an email.

License

This project is licensed under the MIT license. For more information see the LICENSE file.

Copyright 2023 - cheers digital solutions GmbH

Package Sidebar

Install

npm i @cheers-io/nuxt-storyblok-sitemap

Weekly Downloads

35

Version

1.4.0

License

MIT

Unpacked Size

13.2 kB

Total Files

12

Last publish

Collaborators

  • sumerokr
  • bastian-friedrich