@ax2/api-sitemap
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

API SITEMAP MODULE

Setup

Add the dependency

yarn add @ax2/api-sitemap

How to install

If you have only page builder pages in front-end:

import { router as sitemapRouter } from '@ax2/api-sitemap';
const koaRouter = new Router();
koaRouter.use(sitemapRouter);
export default koaRouter;

If you want to add more route to your sitemap, just extend your SitemapService and update getUrls method:

import { Workout } from 'entities/workout/workoutModel';
import { Publication } from 'entities/publication/publicationModel';
import { service, SitemapUrl } from '@ax2/api-sitemap';

class SitemapService extends service {
  /**
  * Get sitemap URLs
  */
  static async getUrls(): Promise<SitemapUrl[]> {
    const langs = this.getLangs();
    return [
      ...await this.getPageUrls(langs, 'daily'),
      ...await this.getEntityUrls(langs, () => Workout.getAll(), { fr: 'filles/entrainements', en: 'girls/workouts'}, 'monthly'),
      ...await this.getEntityUrls(langs, () => Publication.getAll(10), 'publications', 'monthly'), // Articles
      ...await this.getEntityUrls(langs, () => Publication.getAll(5), 'publications', 'monthly'), // Recipes
    ];
  }
}

export default SitemapService;

Available class

import { router as sitemapRouter, controller as sitemapController, service as sitemapService } from '@ax2/api-sitemap';

Readme

Keywords

none

Package Sidebar

Install

npm i @ax2/api-sitemap

Weekly Downloads

1

Version

0.2.2

License

MIT

Unpacked Size

16.2 kB

Total Files

15

Last publish

Collaborators

  • ax2-owner