mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: init sitemaps generation
This commit is contained in:
parent
09c0444284
commit
41a11c5f83
3 changed files with 88 additions and 3 deletions
|
|
@ -21,6 +21,7 @@ export const config = {
|
|||
* 5. all root files inside /public (e.g. /favicon.ico)
|
||||
*/
|
||||
'/((?!api|_next|fonts|umami|examples|[\\w-]+\\.\\w+).*)',
|
||||
'/sitemap.xml',
|
||||
],
|
||||
}
|
||||
|
||||
|
|
@ -99,6 +100,29 @@ export default async function middleware(req: NextRequest) {
|
|||
}
|
||||
}
|
||||
|
||||
if (pathname.startsWith('/sitemap.xml')) {
|
||||
let orgslug: string;
|
||||
|
||||
if (hosting_mode === 'multi') {
|
||||
orgslug = fullhost
|
||||
? fullhost.replace(`.${LEARNHOUSE_DOMAIN}`, '')
|
||||
: (default_org as string);
|
||||
} else {
|
||||
// Single hosting mode
|
||||
orgslug = default_org as string;
|
||||
}
|
||||
|
||||
const sitemapUrl = new URL(`/api/sitemap`, req.url);
|
||||
|
||||
// Create a response object
|
||||
const response = NextResponse.rewrite(sitemapUrl);
|
||||
|
||||
// Set the orgslug in a header
|
||||
response.headers.set('X-Sitemap-Orgslug', orgslug);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
// Multi Organization Mode
|
||||
if (hosting_mode === 'multi') {
|
||||
// Get the organization slug from the URL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue