Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

347
Visualizações
Get route path name inside Nuxt Config file

I have app and I am playing around with sitemap generation. For sitemap I am using @nuxtjs/sitemap - 2.4.0, and my idea is to run some functions for generating sitemaps dynamically only when user opens site map URL and not on every startup of server.

I am using nuxt/vue-app 2.15.8 and I was wondering what is the correct way to access current opened page/path inside Nuxt config file ?

This is config for sitemap itself:

{
    path: '/sitemaps/store-locations.xml',
    exclude: ['!**', '/'], // Skip all automatically generated routes
    i18n: true,
    xmlNs:
      'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"',
    routes: async function () {
      //$route gets undefined
      if (this.$route.path.split('/').pop() !== 'store-locations.xml') return
      
      //heavy functions which makes a lot of calls to DB
      const { getStores } = require('../../helpers/sitemap/storeLocatorRoutes');

      return getStores();
    },
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda