Allow manually configure routes in SSR mode

everyx
0
everyx
commented 7 months ago

What problem does this feature solve?

Thus, when in SSR mode, we can get robots.txt data from api and dynamically generate robots.txt.

like nuxt-community/gtm-module

GTM Initialisation

If you want to block Google Tag Manager before user directly allows (GDPR realisation or other), you can set autoInit option to false and then manually enable using $gtm.init().

Note: All events will be still buffered in data layer but won't send until init() method getting called.

idea
0
NicoPennec
2.1k
NicoPennec
commented 7 months ago

@everyx sorry, I not sur to understand.

What do you mean by "Allow manually configure routes"?
Which kind of routes? (static or dynamic)
Can you give a concrete example on sitemap context, please?

0
everyx
0
everyx
commented 7 months ago

@everyx sorry, I not sur to understand.

What do you mean by "Allow manually configure routes"?
Which kind of routes? (static or dynamic)
Can you give a concrete example on sitemap context, please?

Sorry for my english.

I mean that if we want modify the sitemap content, we must rebuild it, if we can manually init sitemap on server side, we can have a dynamic sitemap.

0
NicoPennec
2.1k
NicoPennec
commented 7 months ago

But the sitemap is already dynamic in SSR mode with the routes option.
To each call to your https://example.org/sitemap.xml, the module will rebuild the sitemap.

See example: https://github.com/nuxt-community/sitemap-module#from-a-function-which-returns-a-promise

0
everyx
0
everyx
commented 7 months ago

But the sitemap is already dynamic in SSR mode with the routes option.
To each call to your https://example.org/sitemap.xml, the module will rebuild the sitemap.

See example: https://github.com/nuxt-community/sitemap-module#from-a-function-which-returns-a-promise

@NicoPennec Yes, but if we use if I use routes: () => // promise or function in nuxt.config.js, it will not re-execution the promise or function, so if we want have a realtime result of this promise or function, we need rebuild the project, so if I have some Dynamic Routes changed from my api, I have no way to do this.

0
NicoPennec
2.1k
NicoPennec
commented 6 months ago

if you need dynamic routes, you have to use the dynamic routes declaration on the sitemap module option.

The promise will be execute to each call of /sitemap.xml and not on build!

Test by your self:

  sitemap: [
    {
      routes: async () => {
        const { data } = await axios.get('http://worldclockapi.com/api/json/utc/now')
        return [`/time/${data.currentFileTime}`]
      },
      cacheTime: 1
    }
  ]

nb: by default the sitemap-module set a cache time of 15 minutes (see options)

0
Informations
Feature Request โ€ข Open
#c81 - Created 7 months ago