jbaubree / vite-plugin-pages-sitemap Goto Github PK
View Code? Open in Web Editor NEWvite-plugin-pages based sitemap generator
License: MIT License
vite-plugin-pages based sitemap generator
License: MIT License
This plugin in not working, and it is not even generating static routes
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import firebase from 'firebase'
import Pages from 'vite-plugin-pages'
import generateSitemap from 'vite-plugin-pages-sitemap'
// https://vitejs.dev/config/
export default defineConfig({
// base: '/deploy',
plugins: [
vue(),
Pages({
onRoutesGenerated: async (routes) => {
// let data = []
// const db = firebase.firestore()
// // retrieve a collection
// db.collection('BlockList')
// .orderBy('time', 'desc')
// .onSnapshot((snapshotChange) => {
// snapshotChange.forEach((doc) => {
// data.push({
// key: doc.id,
// })
// console.log(doc.id)
// })
// })
// console.log(JSON.stringify(data))
// // const users = await api.get('/users')
// const dynamicRoutes = data.map((x) => `/block/${x.key}`)
console.log('routes', routes)
generateSitemap({
hostname: 'https://myquiltblocks.com/',
// routes: [...routes, ...dynamicRoutes],
routes: [...routes],
readable: true,
exclude: [],
allowRobots: true,
})
},
}),
],
})
After updating my dependency's, the sitemap doesn't generate anymore. After this experience I tested the example in your GitHub to test if something was wrong with my config. Unfortunately it wasn't the case the example also doesn't work.
The current state of the plugin doesn't support Vite 3
It should be possible to mix regular expressions with fully qualified strings for route exclusion.
You should specify in your readme, that it only works if you use vite-plugin-pages.
I spent several hours to figure out why it doesn't work, just to know that this is requirement. Not Cool!
I'm having a little trouble understanding and getting this to work.
All installed:
// package.json
"vue": "^3.2.31",
"vue-router": "^4.0.14"
"vite": "^2.9.1",
"vite-plugin-pages": "^0.23.0",
"vite-plugin-pages-sitemap": "^1.2.2"
// vite.config.js
import Pages from 'vite-plugin-pages'
import generateSitemap from 'vite-plugin-pages-sitemap'
export default defineConfig({
plugins: [
vue(),
Pages({
onRoutesGenerated: async(routes) => {
generateSitemap({
// hostname: 'https://mywebsite.com/',
hostname: 'http://localhost:3000/',
routes: [...routes],
readable: true,
})
},
}),
],
})
Only have 2 pages, /
and /menu
.
Upon running npm run build
I was expecting to see a generated sitemap.xml
file 🤔
Also tried this routes: ['/', '/menu'],
What am I doing wrong?!
Do you have any suggestions on how to generate the dynamic routes?
Hello. Thank you for the plugin. It was definitely necessary to have a sitemap solution that works with vue 3 and vite.
I setup as instructed but still cant see any sitemap file generated in the public folder of the project.
It also would be nice if you can give an example on how to use the options for example to change the default "hostname".
Nested routes like examples given in: https://router.vuejs.org/guide/essentials/nested-routes.html do not work with sitemap. This is because
vite-plugin-pages-sitemap/src/index.ts
Line 29 in e6d9f6e
To see sample code on how to recurse through the nested routes:
https://github.com/antfu/vite-ssg/blob/3adec80118d6f008fd2f6ffafcc08cb0101284ce/src/node/utils.ts#L13
Work around is to flatten the hierarchy and pass it to generateSitemap, but supporting it natively would be awesome.
I am facing weird issue where I am able to generate the sitemap and run it locally using localhost:3000/sitemap.xml. I updated the hostname as shown below and when I run it locally I can see the sitemap with my domain name. But after deploying it to firebase the response is blank. Am I missing something? Please guide
onRoutesGenerated: (routes) =>
generateSitemap({
hostname: 'https://mydomainname.web.app/',
dest: 'public',
filename: 'sitemap.xml',
routes,
}),
}),
When you build the app sitemap.xml contains hostname <loc>http://localhost/</loc>
with a slash on the end.
Every next <loc>
looks like this <loc>http://localhostterms-and-privacy</loc>
without the slash at the end of the hostname.
Workaround is to provide routes manually in vite.config.js routes: ['/', '/terms-and-privacy']
which is ok as long as you don't have many routes.
Is it possible for me to generate the sitemap xml file during build only? i searched the 'changefreq' option in the repository and could see if it is possible or not.
Hi,
the plug-in cannot generate sitemap for my website, i am building my website as following :
"dependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-helmet": "^6.1.0",
"react-router-dom": "^6.3.0",
"zustand": "^4.0.0-rc.1"
},
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@vitejs/plugin-react": "^1.3.0",
"sass": "^1.52.3",
"vite": "^3.0.9",
"vite-plugin-pages": "^0.25.0",
"vite-plugin-pages-sitemap": "^1.3.0"
}
the .jsx
which are the single pages are located in the src/views. Then i run npm run build
to build the website, but i get nothing. my vite.config.js look like so:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import Pages from 'vite-plugin-pages'
import generateSitemap from 'vite-plugin-pages-sitemap'
export default defineConfig({
plugins: [
react(),
Pages({
dirs: 'src/views',
onRoutesGenerated: routes =>
generateSitemap({
routes,
readable: true,
dest: 'public',
filename: 'sitemap.xml'
}),
}),
],
server: {
host: true,
},
})
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.github/workflows/ci.yml
actions/checkout v4
pnpm/action-setup v4
actions/setup-node v4
actions/checkout v4
pnpm/action-setup v4
actions/setup-node v4
example/package.json
vue ^3.4.27
vue-router ^4.3.2
@vitejs/plugin-vue ^5.0.4
cross-env ^7.0.3
nodemon ^3.1.0
typescript ^5.4.5
vite ^5.2.11
vite-plugin-pages ^0.32.1
package.json
sitemap ^8.0.0
xml-formatter ^3.6.2
@antfu/eslint-config ^2.18.1
@antfu/utils ^0.7.8
@types/node ^20.12.12
@vitest/coverage-v8 ^1.6.0
eslint ^9.3.0
eslint-plugin-format ^0.1.1
pkgroll ^2.1.1
typescript ^5.4.5
vite ^5.2.11
vitest ^1.6.0
pnpm 9.4.0
Is there possible to customize robots disallow the routes page from the vite-plugin-pages?
And I have problem when generate dynamic routes from api there such an error too.
[vite-plugin-pages] Could not load /@vite-plugin-pages/generated-pages?id=virtual:generated-pages (imported by src/main.js): products.map is not a function
error during build:
TypeError: Could not load /@vite-plugin-pages/generated-pages?id=virtual:generated-pages (imported by src/main.js): products.map is not a function
at Object.onRoutesGenerated (file:///D:/Project/Web%20Brand/web-brand/vite.config.js.timestamp-1664157424389.mjs:36:40)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async computeVueRoutes (file:///D:/Project/Web%20Brand/web-brrand/node_modules/.pnpm/[email protected][email protected]/node_moudules/vite-plugin-pages/dist/index.mjs:514:17)
at async resolveVueRoutes (file:///D:/Project/Web%20Brand/web-brrand/node_modules/.pnpm/[email protected][email protected]/node_moudules/vite-plugin-pages/dist/index.mjs:519:23)
at async file:///D:/Project/Web%20Brand/web-brand/node_modules/..pnpm/[email protected]/node_modules/rollup/dist/es/shared/rollup.js:221113:98
at async Queue.work (file:///D:/Project/Web%20Brand/web-brand/noode_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/orollup.js:22820:32)
ELIFECYCLE Command failed with exit code 1.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.