diff --git a/next-sitemap.config.js b/next-sitemap.config.js index b77dd945..0e2f2c95 100644 --- a/next-sitemap.config.js +++ b/next-sitemap.config.js @@ -2,15 +2,16 @@ const isDeployment = !!process.env.VERCEL_URL; const priorities = { "/": 1.0, + "/simulation": 1.0, "/stats": 0.5, - "/healthz": 0, }; /** @type {import('next-sitemap').IConfig} */ const config = { - generateRobotsTxt: false, + generateRobotsTxt: true, siteUrl: isDeployment ? `https://${process.env.VERCEL_URL}` : "http://localhost:3000", changefreq: "weekly", + exclude: ["/debug", "/debug/*", "/healthz", "/blog/playground"], transform: async (config, path) => { return { loc: path, @@ -20,6 +21,15 @@ const config = { changefreq: config.changefreq, }; }, + robotsTxtOptions: { + policies: [ + { + userAgent: "*", + allow: "/", + disallow: ["/debug", "/debug/*", "/healthz", "/blog/playground"], + }, + ], + }, }; module.exports = config; diff --git a/src/app/(decorated)/(center)/blog/[slug]/page.tsx b/src/app/(decorated)/(center)/blog/[slug]/page.tsx index 13abd74c..f557e07b 100644 --- a/src/app/(decorated)/(center)/blog/[slug]/page.tsx +++ b/src/app/(decorated)/(center)/blog/[slug]/page.tsx @@ -2,7 +2,6 @@ import { type Metadata } from "next"; import Image from "next/image"; import { notFound } from "next/navigation"; -import { baseUrl } from "@/app/sitemap"; import { Button } from "@/components/Button"; import { config } from "@/config"; import { H2 } from "@/dsfr/base/typography"; @@ -10,6 +9,8 @@ import { cn } from "@/utils/cn"; import { formatDate, getBlogPost, getBlogPosts } from "../utils"; +const baseUrl = config.host; + export async function generateStaticParams() { const posts = await getBlogPosts(); diff --git a/src/app/tally/page.tsx b/src/app/debug/tally/page.tsx similarity index 100% rename from src/app/tally/page.tsx rename to src/app/debug/tally/page.tsx diff --git a/src/app/robots.ts b/src/app/robots.ts deleted file mode 100644 index 2bb7e9c3..00000000 --- a/src/app/robots.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { type MetadataRoute } from "next"; - -import { config } from "@/config"; - -const robots = (): MetadataRoute.Robots => { - return config.env === "prod" - ? { - rules: { - userAgent: "*", - allow: "/", - disallow: "/private/", - }, - sitemap: "/sitemap.xml", - } - : { - rules: { - userAgent: "*", - disallow: "/", - }, - }; -}; - -export default robots; diff --git a/src/app/sitemap.ts b/src/app/sitemap.ts deleted file mode 100644 index 3412c6bd..00000000 --- a/src/app/sitemap.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { type MetadataRoute } from "next"; - -import { config } from "@/config"; - -import { getBlogPosts } from "./(decorated)/(center)/blog/utils"; - -export const baseUrl = config.host || "https://pacoupa.ademe.fr/"; - -export default async function sitemap(): Promise { - const blogs = (await getBlogPosts()).map(post => ({ - url: `${baseUrl}/blog/${post.slug}`, - lastModified: post.frontmatter.publishedAt, - })); - - const lastModified = new Date().toISOString().split("T")[0]; - - const routes = [ - { url: `${baseUrl}/`, lastModified }, - { url: `${baseUrl}/simulation`, lastModified }, - { url: `${baseUrl}/contact`, lastModified }, - { url: `${baseUrl}/faq`, lastModified }, - { url: `${baseUrl}/methodologie`, lastModified }, - { url: `${baseUrl}/accessibilite`, lastModified }, - { url: `${baseUrl}/mentions-legales`, lastModified }, - { url: `${baseUrl}/cgu`, lastModified }, - { url: `${baseUrl}/politique-de-confidentialite`, lastModified }, - { url: `${baseUrl}/politique-des-cookies`, lastModified }, - { url: `${baseUrl}/blog`, lastModified }, - ] as MetadataRoute.Sitemap; - - return [...routes, ...blogs]; -} diff --git a/src/config.ts b/src/config.ts index ca01734c..27f9fc09 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,5 @@ export const config = { - host: process.env.NEXT_PUBLIC_SITE_URL!, + host: process.env.NEXT_PUBLIC_SITE_URL! || "https://pacoupa.ademe.fr/", name: "Pacoupa", tagline: "Conseiller les copropriétaires dans l'installation de systèmes de chauffage décarbonés adaptés à leur logement",