diff --git a/src/app/sitemap.ts b/src/app/sitemap.ts index 8e98301..f3a53df 100644 --- a/src/app/sitemap.ts +++ b/src/app/sitemap.ts @@ -14,7 +14,6 @@ type Href = Parameters[0]['href']; const staticRoutes = [ '/', '/pricing', - '/blog', '/docs', '/about', '/contact', @@ -48,88 +47,91 @@ export default async function sitemap(): Promise { }) ); - // add categories - sitemapList.push( - ...categorySource.getPages().flatMap((category) => - routing.locales.map((locale) => ({ - url: getUrl(`/blog/category/${category.slugs[0]}`, locale), - lastModified: new Date(), - priority: 0.8, - changeFrequency: 'weekly' as const, - })) - ) - ); - - // add paginated blog list pages - routing.locales.forEach((locale) => { - const posts = blogSource - .getPages(locale) - .filter((post) => post.data.published); - const totalPages = Math.max( - 1, - Math.ceil(posts.length / websiteConfig.blog.paginationSize) + // add blog related routes if enabled + if (websiteConfig.blog.enable) { + // add categories + sitemapList.push( + ...categorySource.getPages().flatMap((category) => + routing.locales.map((locale) => ({ + url: getUrl(`/blog/category/${category.slugs[0]}`, locale), + lastModified: new Date(), + priority: 0.8, + changeFrequency: 'weekly' as const, + })) + ) ); - // /blog/page/[page] (from 2) - for (let page = 2; page <= totalPages; page++) { - sitemapList.push({ - url: getUrl(`/blog/page/${page}`, locale), - lastModified: new Date(), - priority: 0.8, - changeFrequency: 'weekly' as const, - }); - } - }); - // add paginated category pages - routing.locales.forEach((locale) => { - const localeCategories = categorySource.getPages(locale); - localeCategories.forEach((category) => { - // posts in this category and locale - const postsInCategory = blogSource + // add paginated blog list pages + routing.locales.forEach((locale) => { + const posts = blogSource .getPages(locale) - .filter((post) => post.data.published) - .filter((post) => - post.data.categories.some((cat) => cat === category.slugs[0]) - ); + .filter((post) => post.data.published); const totalPages = Math.max( 1, - Math.ceil(postsInCategory.length / websiteConfig.blog.paginationSize) + Math.ceil(posts.length / websiteConfig.blog.paginationSize) ); - // /blog/category/[slug] (first page) - sitemapList.push({ - url: getUrl(`/blog/category/${category.slugs[0]}`, locale), - lastModified: new Date(), - priority: 0.8, - changeFrequency: 'weekly' as const, - }); - // /blog/category/[slug]/page/[page] (from 2) + // /blog/page/[page] (from 2) for (let page = 2; page <= totalPages; page++) { sitemapList.push({ - url: getUrl( - `/blog/category/${category.slugs[0]}/page/${page}`, - locale - ), + url: getUrl(`/blog/page/${page}`, locale), lastModified: new Date(), priority: 0.8, changeFrequency: 'weekly' as const, }); } }); - }); - // add posts (single post pages) - sitemapList.push( - ...blogSource.getPages().flatMap((post) => - routing.locales - .filter((locale) => post.locale === locale) - .map((locale) => ({ - url: getUrl(`/blog/${post.slugs.join('/')}`, locale), + // add paginated category pages + routing.locales.forEach((locale) => { + const localeCategories = categorySource.getPages(locale); + localeCategories.forEach((category) => { + // posts in this category and locale + const postsInCategory = blogSource + .getPages(locale) + .filter((post) => post.data.published) + .filter((post) => + post.data.categories.some((cat) => cat === category.slugs[0]) + ); + const totalPages = Math.max( + 1, + Math.ceil(postsInCategory.length / websiteConfig.blog.paginationSize) + ); + // /blog/category/[slug] (first page) + sitemapList.push({ + url: getUrl(`/blog/category/${category.slugs[0]}`, locale), lastModified: new Date(), priority: 0.8, changeFrequency: 'weekly' as const, - })) - ) - ); + }); + // /blog/category/[slug]/page/[page] (from 2) + for (let page = 2; page <= totalPages; page++) { + sitemapList.push({ + url: getUrl( + `/blog/category/${category.slugs[0]}/page/${page}`, + locale + ), + lastModified: new Date(), + priority: 0.8, + changeFrequency: 'weekly' as const, + }); + } + }); + }); + + // add posts (single post pages) + sitemapList.push( + ...blogSource.getPages().flatMap((post) => + routing.locales + .filter((locale) => post.locale === locale) + .map((locale) => ({ + url: getUrl(`/blog/${post.slugs.join('/')}`, locale), + lastModified: new Date(), + priority: 0.8, + changeFrequency: 'weekly' as const, + })) + ) + ); + } // add docs const docsParams = source.generateParams(); diff --git a/src/config/footer-config.tsx b/src/config/footer-config.tsx index d2fdbcf..4aadece 100644 --- a/src/config/footer-config.tsx +++ b/src/config/footer-config.tsx @@ -3,6 +3,7 @@ import { Routes } from '@/routes'; import type { NestedMenuItem } from '@/types'; import { useTranslations } from 'next-intl'; +import { websiteConfig } from './website'; /** * Get footer config with translations @@ -41,11 +42,15 @@ export function getFooterLinks(): NestedMenuItem[] { { title: t('resources.title'), items: [ - { - title: t('resources.items.blog'), - href: Routes.Blog, - external: false, - }, + ...(websiteConfig.blog.enable + ? [ + { + title: t('resources.items.blog'), + href: Routes.Blog, + external: false, + }, + ] + : []), { title: t('resources.items.docs'), href: Routes.Docs, diff --git a/src/config/navbar-config.tsx b/src/config/navbar-config.tsx index 3bd9e85..f37c190 100644 --- a/src/config/navbar-config.tsx +++ b/src/config/navbar-config.tsx @@ -34,6 +34,7 @@ import { WandSparklesIcon, } from 'lucide-react'; import { useTranslations } from 'next-intl'; +import { websiteConfig } from './website'; /** * Get navbar config with translations @@ -59,11 +60,15 @@ export function getNavbarLinks(): NestedMenuItem[] { href: Routes.Pricing, external: false, }, - { - title: t('blog.title'), - href: Routes.Blog, - external: false, - }, + ...(websiteConfig.blog.enable + ? [ + { + title: t('blog.title'), + href: Routes.Blog, + external: false, + }, + ] + : []), { title: t('docs.title'), href: Routes.Docs, diff --git a/src/config/website.tsx b/src/config/website.tsx index c37715b..6e4e9c0 100644 --- a/src/config/website.tsx +++ b/src/config/website.tsx @@ -34,12 +34,12 @@ export const websiteConfig: WebsiteConfig = { }, features: { enableDiscordWidget: false, - enableCrispChat: process.env.NEXT_PUBLIC_DEMO_WEBSITE === 'true', enableUpgradeCard: true, enableUpdateAvatar: true, enableAffonsoAffiliate: false, enablePromotekitAffiliate: false, enableDatafastRevenueTrack: false, + enableCrispChat: process.env.NEXT_PUBLIC_DEMO_WEBSITE === 'true', enableTurnstileCaptcha: process.env.NEXT_PUBLIC_DEMO_WEBSITE === 'true', }, routes: { @@ -68,6 +68,7 @@ export const websiteConfig: WebsiteConfig = { }, }, blog: { + enable: false, paginationSize: 6, relatedPostsSize: 3, }, diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 8fe2967..6bea8f1 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -111,6 +111,7 @@ export interface I18nConfig { * Blog configuration */ export interface BlogConfig { + enable: boolean; // Whether to enable the blog paginationSize: number; // Number of posts per page relatedPostsSize: number; // Number of related posts to show }