Skip to content

Commit

Permalink
feat: refactor sitemap and robots file generation
Browse files Browse the repository at this point in the history
  • Loading branch information
pom421 committed Dec 10, 2024
1 parent a942189 commit 8cdc2ec
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 59 deletions.
14 changes: 12 additions & 2 deletions next-sitemap.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -20,6 +21,15 @@ const config = {
changefreq: config.changefreq,
};
},
robotsTxtOptions: {
policies: [
{
userAgent: "*",
allow: "/",
disallow: ["/debug", "/debug/*", "/healthz", "/blog/playground"],
},
],
},
};

module.exports = config;
3 changes: 2 additions & 1 deletion src/app/(decorated)/(center)/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ 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";
import { cn } from "@/utils/cn";

import { formatDate, getBlogPost, getBlogPosts } from "../utils";

const baseUrl = config.host;

export async function generateStaticParams() {
const posts = await getBlogPosts();

Expand Down
File renamed without changes.
23 changes: 0 additions & 23 deletions src/app/robots.ts

This file was deleted.

32 changes: 0 additions & 32 deletions src/app/sitemap.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 8cdc2ec

Please sign in to comment.