Activities

jhd4tmr

jhd4tmr posted a new question

sitemap-module •

How to create several sitemaps to separate the routers?

I have a site with more than 50,000 uris, i want to separate the sitemap.xml to several small parts.

thisischrisj

thisischrisj posted a new question

sitemap-module •

Access the routes object inside the routes function

The filter function passes the routes object to the function call. Is it possible to access that same object from within the routes function call?

We have nuxt.js frontend that pulls data from a WordPress backend. To generate the sitemap we are pulling all the permalink structures from Wordpress inside the routes function:

...
  routes () {
    var endpoint = 'https://xxxx.yyyy/permalinks';
    return axios.get(endpoint)
    .then(res => res.data.map(page => page.permalink))
    .catch((err) => {  });
  }
...

The problem is that the permalinks we get back from WordPress are not necessarily aligned 1-to-1 with the nuxt routes. The ones that aren't can be removed as they are not needed.

What we'd like to do is get all the data from the endpoint and test each page.permalink against the structure of the nuxt routes. If the permalink matches a valid route then include it, otherwise, omit it.

So, imagine we have the following route structures:

blog/:id
news/:id

And the call to the endpoint returns:

[
    { permalink: 'blog/123' },
    { permalink: 'news/123' },
    { permalink: 'case-studies/123' }
}

We want to filter the endpoint results so that 'case-studies/123' is omitted from the sitemap because it is not a valid route.

SnirShechter

SnirShechter posted a new feature request

sitemap-module •

idea Exclude pages from sitemap via in-component options

What problem does this feature solve?

excluding pages via filter function and/or exclude globs is fine for a global configuration.

That being said, sometimes we would like the configuration to be related to the page itself (i.e a terms & conditions page that is duplicated across projects).

What does the proposed changes look like?

Terms.vue

<template>
...
</template>
<script>
export default {
      sitemap:false
}
</script>
<style>
...
</style>

A pull request is available in #70

miteyema

miteyema posted a new question

sitemap-module •

using both filter and defaults does not work when following README.md

If you blindly copy the code from the documentation for both filter (to have trailing slashes) and defaults (to set default values for all routes), the sitemap.xml has URLs with trailing slashes, but the URLs do not have the default values. This is because the map function used in the code example for filter to have trailing slashes, throws away everything but the URL. Changing the documentation would prevent other people having the same issue if they would blindly copy/paste the code from the documentation.

SnirShechter

SnirShechter posted a new feature request

sitemap-module •

idea Filter function should receive the full route object (instead of just the url)

What problem does this feature solve?

The filter function receives an array of routes containing URLs and sitemap options. This means that the only way to filter the route is by final URL:

filter function - received route object

{
      url:'/about-us',
      // ...sitemapOptions
}

The specific need rises when we are using nuxt-i18n:

localed route

routeName: 'about'
urls:{
      en: '/about-us', 
      fr: '/a-propos',
      es: '/sobre' 
}

If I wish to exclude these routes, I need to use one of two options:

sitemapConfig - exclude 'about'

exclude: [
      '/about-us', 
      '/a-propos',
      '/sobre'
]

or

filter function - exclude 'about'

filter(routes){
      const excludedRoutes =  ['/about-us', '/a-propos', '/sobre']
      return routes.filter(route=>!excludedRoutes.includes(route.url))
}

What does the proposed changes look like?

The route object can actually contain more data:

filter function - possible route object

{
      url:'/about-us',
      name:'about',
      path:'/',
      chunkName:'pages/index',
      component:'C:\dev\sitemap-module\test\fixture\pages\about.vue'
}

Using that data, we can easily exclude routes by name.

filter function - new form

filter(routes){
      const excludedRouteNames =  ['about']
      return routes.filter(route=>!excludedRouteNames .includes(route.name))
}
Jered

Jered posted a new feature request

sitemap-module •

idea Support sitemap creation when using generate payload

What problem does this feature solve?

When using generate with dynamic routes you return the routes as an array of string URLs which the sitemap module picks up and creates a correct sitemap.xml. However, if you return the routes object from generate to use the payload feature, the sitemap will fail because it expects a string instead of an object.

What does the proposed changes look like?

Make it so sitemap can use generate.routes when using payloads. Should be updated to also accept routes in the form of:

[
  {
    route: 'urlstring', 
    payload: {data object},
    ...
  }
]

and extract the route.

ilyaskorik

ilyaskorik posted a new question

sitemap-module •

The meaning of the exclude parameter is not clear.

Judging by the code, it filters the routes of nuxt, and not the final xml file data. In my case it does not work. Can you fix this and filter the final data?

fabsfabs

fabsfabs posted a new question

sitemap-module •

How to exclude the root, without the trailing slash, from the sitemap?

Hi everyone

a simple question, I hope.
I'm able to exlude the website root from the sitemap adding the '/' route inside the exclude array like so:
Screenshot 2019-06-04 at 09.17.21.png

Otherwise it exclude just the following route: https://www.my-domain.com/
The below route still remains in the sitemap
Screenshot 2019-06-04 at 09.20.30.png

So what is the line I have to wrote to exclude the path without the trailing slash?

Many thanks

NicoPennec

NicoPennec resolved the question #c44

sitemap-module •

How does cache work?

Thanks for the encouragements @Jesus82 👍

About the cache system, it's driven by the back-end Node.js, so it's Universal mode only. It's a server-side global cache and therefore shared between all IP addresses or any HTTP requests.

AlexBa

AlexBa posted a new question

sitemap-module •

Wrong routes with /_nuxt/ prefix in sitemap

Version
v1.0.0

Reproduction link
https://alexanderbarton.de/sitemap.xml

Steps to reproduce
Just generate the sitemap with the config. :)

What is expected ?
Routes in sitemap without the /_nuxt/ prefix

What is actually happening?
Routes in sitemap with /_nuxt/ prefix

Additional comments?
This is my nuxt.config.js:

const pkg = require('./package');
const dotenv = require('dotenv');

dotenv.config();

module.exports = {
mode: 'universal',

/*
** Headers of the page
*/
head: {
title: pkg.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: pkg.description }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
]
},

/*
** Customize the progress-bar color
*/
loading: false,

/*
** Global CSS
*/
css: [
'~assets/scss/style.scss',
],

/*
** Plugins to load before mounting the App
*/
plugins: [
{src: '~plugins/bootstrap-native', ssr: false},
{src: '~plugins/tiny-slider', ssr: false}
],

/*
** Nuxt.js modules
*/
modules: [
'@nuxtjs/dotenv',
'@nuxtjs/axios',
'@nuxtjs/redirect-module',
['@nuxtjs/google-tag-manager', {
id: process.env.GTMCONTAINERID
}],
['nuxt-i18n', {
strategy: 'prefixexceptdefault',
defaultLocale: 'de',
lazy: true,
langDir: 'translations/',
locales: [
{
code: 'de',
file: 'de.json'
}
],
}],
'@nuxtjs/sitemap'
],

axios: {
// proxyHeaders: false
},

redirect: [
{ from: '^/datenschutz-erklaerung', to: '/datenschutz' }
],

/*
** Build configuration
*/
build: {
extend(config) {
config.module.rules.push({
test: /bootstrap.native/,
use: {
loader: 'bootstrap.native-loader',
options: {
only: ['collapse', 'modal']
}
}
});
}
}
};

manastalukdar

manastalukdar posted a new bug report

sitemap-module •

bug filter option with map results in error

Version

1.0.0

Reproduction link

https://github.com/manastalukdar/manastalukdar.github.io

Steps to reproduce

Run "npm run nuxt-generate" from the folder website.

Results in error: Url must be a string. Received undefined

sitemap.xml does not get generated.

If I remove the filter option, everything works correctly.

Problematic code:

filter({ routes }) {
      return routes.map(route => {
        if (!route.url.endsWith('.xml') && !route.url.endsWith('/')) {
          route.url = `${route.url}/`
        }
      })
    },

I have verified that the Url has the correct value. I have also tried type casting it explicitly to String, without success.

What is expected ?

sitemap.xml gets generated and the filter option works as expected.

What is actually happening?

Results in error: Url must be a string. Received undefined

sitemap.xml does not get generated.

j574144

j574144 posted a new feature request

sitemap-module •

idea set sitemapConfig.xslUrl

What problem does this feature solve?

Improve style of sitemap presentation

What does the proposed changes look like?

as is used in sitemap.js, pleaase add to defaults the xslUrl option.

Timkor

Timkor posted a new feature request

sitemap-module •

idea HTTPS with req.headers.host icw proxy

What problem does this feature solve?

I would like to generate https links while nuxt runs without ssl. The proxy handles this.

What does the proposed changes look like?

A new config property which can force the generated links to use https.

https://github.com/nuxt-community/sitemap-module/blob/5d029a29443862bc6f8b5c141b3b01f9312f909c/lib/module.js#L152

miguelskeeled

miguelskeeled posted a new question

sitemap-module •

Localized sitemap links duplicating

Hi,

I'm trying to implement a localized sitemap following Google's instructions (https://webmasters.googleblog.com/2012/05/multilingual-and-multinational-site.html). I managed to add the localized links to the sitemap like the following example:

<url> <loc>https://www.example.com/customers</loc> <xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/de/kunden" /> <xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/en/customers" /> <xhtml:link rel="alternate" hreflang="fr" href="https://www.example.com/fr/clients" /> <xhtml:link rel="alternate" hreflang="nl" href="https://www.example.com/nl/klanten" /> </url>

The problem is that after having this <url> entry, it is also generating the following <url> entries:
<url> <loc>https://www.example.com/customers</loc> </url> <url> <loc>https://www.example.com/fr/clients</loc> </url> <url> <loc>https://www.example.com/nl/klanten</loc> </url> <url> <loc>https://www.example.com/de/kunden</loc> </url>

In my website, all the pages are multilanguage so I included all my routes in the routes property of the sitemap in nuxt.config.js, and all the routes are having this duplication issue.

This is my sitemap configuration:
sitemap: { path: '/sitemap.xml', hostname: 'https://www.example.com', cacheTime: 1000 * 60 * 15, gzip: true, generate: true, routes: sitemapLinks(), }

This sitemapLinks is a synchronous function that returns an array of objects and each object has the following structure:

{ url: '/customers', links: [ { lang: 'de', url: 'de/kunden' }, { lang: 'en', url: 'customers' }, { lang: 'fr', url: 'fr/clients' }, { lang: 'nl', url: 'nl/klanten' } ]}

I have a CMS's API which I call when I run my app. This call retrieves all the pages I have in my website, and I put these routes in a static file. I then use this static file to generate the links for the sitemap routes property, to generate the pages of nuxt-i18n and also to generate the components dynamically for each page on router extendRoutes property.

I also included this module after the nuxt-i18n in nuxt.config.js.

So my problem is that basically, I'm sending all my routes with the structure showed previously to the routes property of the sitemap module, the module is generating the localized sitemap correctly, but then duplicates all the routes with a different structure in the sitemap. Am I doing anything wrong or am I missing anything?

Jesus82

Jesus82 posted a new question

sitemap-module •

How does cache work?

Hi, I have a sitemap that needs several api calls with axios in order to get all the routes, so it slows down the page loading. My question is how does exactly the cache of this module work?
If for example user A checks the page, then he cames back in 6 hours, it is clear that the sitemap will not be rebuilt. But what if user A checks the page, and then user B checks it from another IP after 6 hours? Would in that case be rebuilt for user B?

Thanks in advance and congrats for the great module!

bdrtsky

bdrtsky posted a new question

sitemap-module •

How to add lastmodISO with non-dynamic routes?

Docs covering mostly dynamic routes. I am using default settings, since I have siple website without API. So how do I add lastmodISO etc to sitemap then? It just list links by default.

bdrtsky

bdrtsky posted a new question

sitemap-module •

...

yutahaga

yutahaga posted a new bug report

sitemap-module •

bug Generation fails with --no-build option

Version

ceae48b1fc5566be1cdbe74e989ad4495968f8b5

Reproduction link

https://codesandbox.io/s/6118w7omwz

Steps to reproduce

Run yarn generate.

What is expected ?

Fix fatal error.

What is actually happening?

When I run nuxt generate --no-build, the following error occurs:

FATAL  Cannot read property 'get' of null

  at nuxt.hook (node_modules/@nuxtjs/sitemap/src/index.js:60:32)
  at utils.sequence.fn (node_modules/@nuxt/core/dist/core.js:436:53)
  at promise.then (node_modules/@nuxt/utils/dist/utils.js:1664:43)

Additional comments?

router.extendRoutes are ignored when with --no-build option, so no cache is generated.

vedees

vedees posted a new question

sitemap-module •

How to use this map data with Dynamic routes?

My code:

 return axios.all([
     axios.get('https://jsonplaceholder.typicode.com/users'),
     axios.get('https://jsonplaceholder.typicode.com/ico')
 ])
 .then(axios.spread((users, ico) => [...users.data, ...ico.data]))

How to use this?

 {
         url: '/page/2',
         changefreq: 'daily',
         priority: 1,
         lastmodISO: '2017-06-30T13:30:00.000Z'
 }


With Dynamic routes? Right now it's assigning only url.

derevandal

derevandal posted a new feature request

sitemap-module •

idea Feature request: add last modification date

What problem does this feature solve?

Adding <lastmod>2019-01-23</lastmod> in a url tag, search engines will know how this content changed and when it was added and improve the pagerank.

What does the proposed changes look like?

I suggest to use fs.stat(path, [callback]) to read mtime stat of .vue's file or .md's (I wanna use to a blog system, so, it be helpfull this support) and write in sitemap.xml