faustjs
faustjs copied to clipboard
RFC: Enhance `getSitemapProps` in Faust.js for Automatic Frontend URL Retrieval
Summary
I'm proposing an enhancement to Faust.js' getSitemapProps
function to automatically determine the frontend URL, aiming to improve the developer experience. This change would eliminate the need for developers to manually specify the frontendUrl
, thus streamlining the sitemap creation process.
Motivation 🧠
Currently, the frontend URL is manually specified in Faust.js. This requirement can be cumbersome, especially when managing multiple environments like development, staging, and production.
// (current) pages/sitemap.xml.js
import { getSitemapProps } from '@faustwp/core';
export default function Sitemap() {}
export function getServerSideProps(ctx) {
return getSitemapProps(ctx, {
frontendUrl: process.env.FRONTEND_URL,
});
}
Automating this process would simplify sitemap creation and reduce potential configuration errors. ✨
Proposed Solution 💡
Enhance the getSitemapProps
function to automatically retrieve the already known Frontend URL from WordPress, or create a helper function such as getCurrentUrlSSR that uses something like ctx.req
.
// (proposed) pages/sitemap.xml.js
import { getSitemapProps } from '@faustwp/core';
export default function Sitemap() {}
export function getServerSideProps(ctx) {
return getSitemapProps(ctx); // No longer necessary to manually specify frontendUrl
}
Benefits
- Saves Time - Automatically determining the frontend URL reduces the initial setup steps and simplifies the configuration process.
- Reduced Errors - Minimizes the risk of errors associated with manually setting environment variables.
- Flexibility - Maintains flexibility by allowing overrides when necessary.
Furthering Community Impact ⚡
Including an updated sitemap.xml.js
in the following places eliminates the need for Faust users to configure the basics of enabling a sitemap.
- [ ] https://github.com/wpengine/faust-scaffold
- [ ] https://github.com/wpengine/faust-scaffold-ts
- [ ] https://github.com/wpengine/atlas-blueprint-portfolio
- [ ] https://github.com/wpengine/faustjs/tree/canary/examples/next/faustwp-getting-started/
Request for Comments 💬
I’m seeking feedback on the feasibility, potential challenges, and community interest in this feature. Any insights would be greatly appreciated!