-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(vite-plugin-nitro): add initial support for sitemap generation #497
feat(vite-plugin-nitro): add initial support for sitemap generation #497
Conversation
Add sitemap generation for users upon passing a small config object.
Followup - removed unnecessary property in vite.config.ts files in apps
✅ Deploy Preview for analog-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-blog ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Minor changes
apps/blog-app/vite.config.ts
Outdated
@@ -26,6 +26,9 @@ export default defineConfig(() => { | |||
'/blog/2022-12-31-my-second-post', | |||
]; | |||
}, | |||
sitemap: { | |||
domain: 'example.com/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use the deployment URL
domain: 'example.com/', | |
domain: 'https://analog-blog.netlify.app/', |
|
||
if (routeList.length) { | ||
const sitemapData: PagesJson[] = routeList.map((page: string) => ({ | ||
page: `https://www.${sitemapConfig.domain}${page.replace(/^\/+/g, '')}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let the user customize the entire host, for example https://myblog.dev
page: `https://www.${sitemapConfig.domain}${page.replace(/^\/+/g, '')}`, | |
page: `${sitemapConfig.host}${page.replace(/^\/+/g, '')}`, |
apps/analog-app/vite.config.ts
Outdated
@@ -32,6 +32,9 @@ export default defineConfig(({ mode }) => { | |||
apiPrefix: 'api', | |||
prerender: { | |||
routes: ['/', '/cart'], | |||
sitemap: { | |||
domain: 'example.com/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the custom base URL for this example
domain: 'example.com/', | |
domain: process.env['VITE_ANALOG_PUBLIC_BASE_URL'], |
@@ -155,6 +156,7 @@ | |||
"vite-plugin-eslint": "^1.8.1", | |||
"vite-tsconfig-paths": "4.2.0", | |||
"vitest": "0.32.2", | |||
"webpack-bundle-analyzer": "^4.7.0" | |||
"webpack-bundle-analyzer": "^4.7.0", | |||
"xmlbuilder2": "^3.0.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be added to the dependencies
in packages/platform/package.json
also
} | ||
|
||
export interface SitemapConfig { | ||
domain: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
domain: string; | |
host: string; |
|
||
const mapPath = `${path.resolve( | ||
'dist', | ||
config.root!, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a fallback root
config.root!, | |
config.root || '.', |
@@ -0,0 +1,73 @@ | |||
import { SitemapConfig } from './options'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: put local imports last
import { SitemapConfig } from './options'; | |
import { SitemapConfig } from './options'; |
Followup - Fix PR comments. Update config and properties in the config files with examples.
Thanks for the review. Made requested changes. |
Followup - Add check for slash to display or not to avoid doubles
Thanks! @allcontributors add @QuantariusRay for code |
I've put up a pull request to add @QuantariusRay! 🎉 |
…nalogjs#497) Co-authored-by: Q <q.ray@jbhunt.com>
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Which package are you modifying?
What is the current behavior?
Closes #307
What is the new behavior?
Added a config property in pre-render (though, now, that could probably change in the end). This ends up being a property that is just used to generate the domain name needed... I'm open to changing that to a top-level property, I think it'll make more sense.
Does this PR introduce a breaking change?
Other information
[optional] What gif
none yet :(