🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ax2/api-sitemap

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ax2/api-sitemap

## Setup

latest
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

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';

FAQs

Package last updated on 09 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts