Closed pascalwengerter closed 9 months ago
Hi @pascalwengerter
This is an interesting one, You could use the sitemap:resolved nitro hook to filter out the URLs the sitemap based on your endpoint URLs, but it's not that elegant.
I may consider adding a runtime way to do this, but for now I'd recommend doing this within a custom Nuxt module and extend the route rules. This will allow the sitemap module to automatically ignore these URLs, if you're using nuxt-simple-robots, it will also add the correct headers no index headers for you.
Something like this.
import { $fetch } from 'ofetch'
import { defu } from 'defu'
export default defineNuxtConfig({
modules: [
(_, nuxt) => {
const blockedUrls = await $fetch('/cms/blocked-urls')
for (const url of blockedUrls) {
nuxt.options.nitro.routeRules[url] = defu({ index: false }, nuxt.options.nitro.routeRules[url])
}
}
]
})
Let me know if you have any questions
This is possible now with the latest nuxt-simple-robots, see the docs here: https://nuxtseo.com/robots/nitro-api/nitro-hooks#robotsconfig
This module uses getPathRobotConfig()
which is reading off of this config.
Describe the bug
https://nuxtseo.com/sitemap/api/nitro-hooks still contains a link to https://nuxtseo.com/sitemap/api/nuxt-hooks, which is a dead link / empty page.
Regarding the closed #156 - where/how do I pass my noIndex URLs that I've fetched from the headless CMS to the sitemap module to exclude them? Creating a string array in a
nitro:config
hook is easy, passing said array to theexclude
option not so much..Reproduction
No response
System / Nuxt Info
No response