Files
myeasycms-v2/apps/web/app/server-sitemap.xml/route.ts
giancarlo ee507e0816 Refactor code and improve usage of package dependencies
This commit updates the naming convention of icons from Lucide-React, moving some package dependencies to "peerDependencies" in 'team-accounts', 'admin' and 'auth'. Additionally, it includes tweaks to the development server command in apps/web package.json and adds a logger reference to the shared package. Furthermore, cleanup work has been performed within the features and UI packages, and new scripts to interact with Stripe have been added to the root package.json.
2024-03-26 01:34:19 +08:00

45 lines
1.1 KiB
TypeScript

import { invariant } from '@epic-web/invariant';
import { allDocumentationPages, allPosts } from 'contentlayer/generated';
import { getServerSideSitemap } from 'next-sitemap';
import appConfig from '~/config/app.config';
invariant(appConfig.url, 'No NEXT_PUBLIC_SITE_URL environment variable found');
export async function GET() {
const urls = getSiteUrls();
const posts = getPostsSitemap();
const docs = getDocsSitemap();
return getServerSideSitemap([...urls, ...posts, ...docs]);
}
function getSiteUrls() {
const urls = ['/', 'faq', 'pricing'];
return urls.map((url) => {
return {
loc: new URL(url, appConfig.url).href,
lastmod: new Date().toISOString(),
};
});
}
function getPostsSitemap() {
return allPosts.map((post) => {
return {
loc: new URL(post.url, appConfig.url).href,
lastmod: new Date().toISOString(),
};
});
}
function getDocsSitemap() {
return allDocumentationPages.map((page) => {
return {
loc: new URL(page.url, appConfig.url).href,
lastmod: new Date().toISOString(),
};
});
}