Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude page routes but keep dynamic endpoint routes #139

Closed
DarkHiito opened this issue Sep 19, 2023 · 5 comments
Closed

Exclude page routes but keep dynamic endpoint routes #139

DarkHiito opened this issue Sep 19, 2023 · 5 comments

Comments

@DarkHiito
Copy link

Details

Hi guys,

I've got an endpoint on my API which returns me all the URLs that I want to display in my sitemap, so I've setted up my config like bellow :

sitemap: {
    autoI18n: false,
    inferStaticPagesAsRoutes: false,
    sitemaps: {
        fr: { dynamicUrlsApiEndpoint: `http://api.${process.env.BASE_DOMAIN}.fr/v1/sitemap` },
        eu: { dynamicUrlsApiEndpoint: `http://api.${process.env.BASE_DOMAIN}.eu/v1/sitemap` },
    }
}

The issue is that I don't want the sitemap to display any of the Nuxt pages, I only want those ones from my API.
I've tried to add include: [] or exclude: ['/**'] but it also excludes the routes from my API.

Can you advise me how can I managed to do what I want ?

Thank you

@harlan-zw
Copy link
Collaborator

Hi @DarkHiito, thanks for the issue.

You can try enabling the debug mode and visiting /api/__sitemap__/debug, this should show you where it's pulling the URLs from. If you send me the output and what you're trying to remove, I can guide you on how to remove it.

@DarkHiito
Copy link
Author

Hi @harlan-zw, thank you for your answer !
Here is the sources that it returns me, I only want to keep all those that are in api context, and exclude all those that are in nuxt-config.module

"_sources": [
    {
      "context": "nuxt-config.module",
      "path": "urls",
      "urls": 21,
      "count": 21
    },
    {
      "context": "api",
      "timeTakenMs": 111,
      "path": "http://api.stockdev.co.uk/v1/sitemap_marketplace.xml",
      "urls": 57,
      "count": 57
    },
    {
      "context": "api",
      "timeTakenMs": 110,
      "path": "http://api.stockdev.es/v1/sitemap_marketplace.xml",
      "urls": 57,
      "count": 57
    },
    {
      "context": "api",
      "timeTakenMs": 116,
      "path": "http://api.stockdev.eu/v1/sitemap_marketplace.xml",
      "urls": 57,
      "count": 57
    },
    {
      "context": "api",
      "timeTakenMs": 123,
      "path": "http://api.stockdev.fr/v1/sitemap_marketplace.xml",
      "urls": 57,
      "count": 57
    },
    {
      "context": "api",
      "timeTakenMs": 119,
      "path": "http://api.stockdev.nl/v1/sitemap_marketplace.xml",
      "urls": 57,
      "count": 57
    },
    {
      "context": "api",
      "timeTakenMs": 124,
      "path": "http://api.stockdev.de/v1/sitemap_marketplace.xml",
      "urls": 57,
      "count": 57
    }
  ],

@DarkHiito
Copy link
Author

@harlan-zw Up ? 😅

@harlan-zw
Copy link
Collaborator

Hey, thanks for the bump.

This should be fixed in 3.3.5. The URLs seem to have been coming from the i18n.pages config, this will now respect the autoI18n config.

@DarkHiito
Copy link
Author

It's working well with 3.3.5, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants