Hello, I recently completed migrating from vue3 to nuxt3, and now I'm trying to apply a dynamic sitemap.
The URL category is divided into 10 types of URL structures as shown below.
https://bangab.co.kr
https://bangab.co.kr/apt/{dynamicVar}
https://bangab.co.kr/apt_gab/{dynamicVar}
https://bangab.co.kr/office/{dynamicVar}
https://bangab.co.kr/office_gab/{dynamicVar}
https://bangab.co.kr/lotto/{dynamicVar}
https://bangab.co.kr/static/{dynamicVar}
https://bangab.co.kr/news
I have installed it with the command (npm install -D nuxt-simple-sitemap), and I want to configure a sitemap index to create a sitemap for the above 8 types of URLs by category.
I would like to fill in the sitemap contents by calling the backend api (https://api.bangab.co.kr/api) for each sitemap item in the sitemap index, but I am not sure how to do this.
Also, since the capacity for each sitemap is too large, would it be a good idea to enable gzip? If it's a good idea to enable gzip, please tell me how.
I want to collect a new site map every day, and change it to the collection date like lastmod: new Date().
Therefore, when you access https://bangab.co.kr/sitemap.xml, the sitemap index appears, and when I enter the sub-sitemap.xml, I want to see a list of URLs.
tell me how Please.
The source code below is the part where sitemap should be applied inside nuxt.config.js.
import { defineNuxtConfig } from "nuxt/config";
export default defineNuxtConfig({
...
modules: [
"@element-plus/nuxt",
"nuxt-simple-sitemap",
"nuxt-simple-robots",
"nuxt-seo-experiments",
],
...
sitemap: {
// provide dynamic URLs to be included
urls: async () => {
const data = [
{ id: "1", name: "AptGab1" },
{ id: "2", name: "AptGab2" },
{ id: "3", name: "AptGab3" },
];
return data.map((item) => ({
loc: /test/${item.id},
lastmod: new Date(),
changefreq: "daily",
priority: 0.8,
}));
},
},
});