@ax2/api-sitemap
v0.2.2
Published
## Setup
Downloads
9
Readme
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';