@fabrix/spool-sitemap

Sitemap - Spool for Fabrix to generate Sitemaps through a common API

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
30Sep 17, 2018Aug 7, 2018Minified + gzip package size for @fabrix/spool-sitemap in KB

Readme

spool-sitemap

Gitter NPM version Build Status Test Coverage Dependency Status Follow @FabrixApp on Twitter

Sitemap for Fabrix Apps. Creates a sitemap.xml available at /sitemap.xml, and rebuilds on a cron schedule.

Install

$ npm install --save @fabrix/spool-sitemap

Configure

Require the spool

// config/main.ts
import { SitemapSpool } from '@fabrix/spool-sitemap'
export const main = {
  spools: [
    // ... other spools
    SitemapSpool
  ]
}

Configure the spool

// config/sitemap.ts
export const sitemap = {
  host: 'https://<hostname>',
  cache: 1000000
}

Run the Build Cronjob

// config/engine
...
crons_config: {
  auto_schedule: true,
  uptime_delay: 180,
  profiles: {
    development: [
      'SitemapsCron.build'
    ]
  }
}

Creating a Sitemap

Sitemaps are created in the /api/sitemaps. Create one or many methods that return a Promise and array like the one below. Under the hood, Sitemap uses Sitemap for more examples on acceptable returns.

The sitemap is broken into methods so that it can deliver multiple sitemaps if necessary and break them up accordingly.

import { Sitemap } from '@fabrix/spool-sitemap')

export class TestSitemap extends Sitemap {
  test() {
    return Promise.resolve([
      { url: '/page-1/',  changefreq: 'daily', priority: 0.3 },
      { url: '/page-2/',  changefreq: 'monthly',  priority: 0.7 },
      { url: '/page-3/', img: 'http://urlTest.com' }
    ])
  }
}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.