Skip to content

Commit e223bac

Browse files
committed
chore: improve SEO and GEO
1 parent f24bcc2 commit e223bac

12 files changed

Lines changed: 323 additions & 5 deletions

File tree

app/(public)/outils/[tool]/[equivalent]/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ type Props = {
1313
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
1414
}
1515

16+
const prefixes: Record<string, string> = {
17+
fr: 'Empreinte carbone',
18+
en: 'Carbon footprint',
19+
es: 'Huella de carbono',
20+
}
21+
1622
export async function generateMetadata(props: Props, parent: ResolvingMetadata): Promise<Metadata> {
1723
const searchParams = await props.searchParams
1824
const params = await props.params
@@ -30,7 +36,7 @@ export async function generateMetadata(props: Props, parent: ResolvingMetadata):
3036

3137
const language = (searchParams.language as string) || 'fr'
3238
return {
33-
title: `${getName(language, equivalent)} | Impact CO₂`,
39+
title: `${prefixes[language]} ${getName(language, equivalent)} | Impact CO₂`,
3440
description:
3541
language === 'en'
3642
? `Discover the carbon impact of a ${getName(language, equivalent, true, 1, true)} thanks to CO2 Impact and ADEME data`

app/(public)/outils/[tool]/page.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Category from 'components/outils/CategoryPage'
55
import Outil from 'components/outils/Outil'
66
import { simulators } from 'components/outils/simulators'
77
import { getCategory } from 'utils/category'
8+
import { toolsJsonLd } from 'utils/jsonLd'
89
import { metaDescriptions, metaTitles } from 'utils/meta'
910
import { devTools, smallTools } from 'components/cards/tools'
1011
import Suggestion from 'components/layout/Suggestion'
@@ -17,7 +18,7 @@ export async function generateStaticParams() {
1718
tool: tool.slug,
1819
})),
1920
...categories.map((category) => ({ tool: category.slug })),
20-
]
21+
].filter(({ tool }) => tool !== 'caspratiques')
2122
}
2223

2324
type Props = {
@@ -29,6 +30,10 @@ export async function generateMetadata(props: Props, parent: ResolvingMetadata):
2930
const searchParams = await props.searchParams
3031
const params = await props.params
3132
const tool = tools.find((tool) => tool.slug === params.tool)
33+
if (params.tool === 'caspratiques') {
34+
return parent as Metadata
35+
}
36+
3237
if (tool) {
3338
return {
3439
title: `${tool.title} | Impact CO₂`,
@@ -60,9 +65,15 @@ const OutilPage = async (props: Props) => {
6065
const params = await props.params
6166
const tool = tools.find((tool) => tool.slug === params.tool)
6267

68+
if (params.tool === 'caspratiques') {
69+
return notFound()
70+
}
71+
72+
const jsonLd = toolsJsonLd[params.tool]
6373
if (tool) {
6474
return (
6575
<>
76+
{jsonLd && <script type='application/ld+json' dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />}
6677
<Outil tool={tool} />
6778
<Suggestion fromLabel={tool.title} simulatorName={`de l'outil ${tool.title}`} />
6879
</>
@@ -72,6 +83,7 @@ const OutilPage = async (props: Props) => {
7283
if (category) {
7384
return (
7485
<>
86+
{jsonLd && <script type='application/ld+json' dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />}
7587
<Category
7688
category={category}
7789
simulator={simulators[params.tool]}

app/(public)/outils/alimentation/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Metadata } from 'next'
22
import AlimentationPage from 'src/views/AlimentationPage'
3+
import { toolsJsonLd } from 'utils/jsonLd'
34
import { metaDescriptions, metaTitles } from 'utils/meta'
45
import Suggestion from 'components/layout/Suggestion'
56

@@ -21,6 +22,10 @@ export async function generateMetadata(props: {
2122
const Alimentation = async () => {
2223
return (
2324
<>
25+
<script
26+
type='application/ld+json'
27+
dangerouslySetInnerHTML={{ __html: JSON.stringify(toolsJsonLd.alimentation) }}
28+
/>
2429
<AlimentationPage />
2530
<Suggestion fromLabel='Alimentation' simulatorName='de la thématique Alimentation' />
2631
</>

app/(public)/outils/comparateur/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Metadata } from 'next'
22
import ComparateurPage from 'components/outils/comparateur/ComparateurPage'
3+
import { toolsJsonLd } from 'utils/jsonLd'
34
import { metaDescriptions, metaTitles } from 'utils/meta'
45
import Suggestion from 'components/layout/Suggestion'
56

@@ -39,6 +40,10 @@ export async function generateMetadata(props: {
3940
const page = () => {
4041
return (
4142
<>
43+
<script
44+
type='application/ld+json'
45+
dangerouslySetInnerHTML={{ __html: JSON.stringify(toolsJsonLd.comparateur) }}
46+
/>
4247
<ComparateurPage />
4348
<Suggestion fromLabel='Comparateur' simulatorName='du comparateur carbone' />
4449
</>

app/(public)/outils/habillement/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Metadata } from 'next'
22
import HabillementPage from 'src/views/HabillementPage'
3+
import { toolsJsonLd } from 'utils/jsonLd'
34
import { metaDescriptions, metaTitles } from 'utils/meta'
45
import Suggestion from 'components/layout/Suggestion'
56

@@ -33,6 +34,10 @@ export async function generateMetadata(props: {
3334
const Habillement = async () => {
3435
return (
3536
<>
37+
<script
38+
type='application/ld+json'
39+
dangerouslySetInnerHTML={{ __html: JSON.stringify(toolsJsonLd.habillement) }}
40+
/>
3641
<HabillementPage />
3742
<Suggestion fromLabel='Habillement' simulatorName='de la thématique Habillement' />
3843
</>

app/(public)/outils/livraison/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Metadata } from 'next'
22
import LivraisonPage from 'src/views/LivraisonPage'
3+
import { toolsJsonLd } from 'utils/jsonLd'
34
import { metaDescriptions, metaTitles } from 'utils/meta'
45
import Suggestion from 'components/layout/Suggestion'
56

@@ -32,6 +33,7 @@ export async function generateMetadata(props: {
3233
const Livraison = async () => {
3334
return (
3435
<>
36+
<script type='application/ld+json' dangerouslySetInnerHTML={{ __html: JSON.stringify(toolsJsonLd.livraison) }} />
3537
<LivraisonPage />
3638
<Suggestion fromLabel='Livraison' simulatorName='de la thématique Livraison' />
3739
</>

app/(public)/outils/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { Metadata } from 'next'
22
import Outils from 'components/outils/Outils'
3+
import { outilsJsonLd } from 'utils/jsonLd'
34
import Suggestion from 'components/layout/Suggestion'
45

56
export const metadata: Metadata = {
67
title: 'Outils | Impact CO₂',
78
description:
8-
"Trouver le bon outil adapté à son contenu dans le catalogue de ressources personnalisables dImpact CO2 pour sensibiliser à l'empreinte carbone.",
9+
"Trouver le bon outil adapté à son contenu dans le catalogue de ressources personnalisables d'Impact CO2 pour sensibiliser à l'empreinte carbone.",
910
}
1011

1112
const OutilsPage = () => {
1213
return (
1314
<>
15+
<script type='application/ld+json' dangerouslySetInnerHTML={{ __html: JSON.stringify(outilsJsonLd) }} />
1416
<Outils />
1517
<Suggestion fromLabel='Outils' simulatorName='du site' />
1618
</>

app/(public)/outils/quiz/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Metadata } from 'next'
22
import QuizPage from 'components/outils/quiz/QuizPage'
3+
import { toolsJsonLd } from 'utils/jsonLd'
34
import { metaDescriptions, metaTitles } from 'utils/meta'
45
import Suggestion from 'components/layout/Suggestion'
56

@@ -21,6 +22,7 @@ export async function generateMetadata(props: {
2122
const page = () => {
2223
return (
2324
<>
25+
<script type='application/ld+json' dangerouslySetInnerHTML={{ __html: JSON.stringify(toolsJsonLd.quiz) }} />
2426
<QuizPage />
2527
<Suggestion fromLabel='Quiz carbone' simulatorName='du quiz carbone' />
2628
</>

app/(public)/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Metadata } from 'next'
2+
import { homeJsonLd } from 'utils/jsonLd'
23
import Home from 'components/home/Home'
34
import Suggestion from 'components/layout/Suggestion'
45

@@ -9,6 +10,7 @@ export const metadata: Metadata = {
910
const HomePage = () => {
1011
return (
1112
<>
13+
<script type='application/ld+json' dangerouslySetInnerHTML={{ __html: JSON.stringify(homeJsonLd) }} />
1214
<Home />
1315
<Suggestion fromLabel='Accueil' simulatorName='du site' />
1416
</>

next.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ const nextConfig = {
9898
return [
9999
{
100100
source: '/detecteur-co2',
101-
destination: '/contenu/detecteur-co2',
101+
destination: '/outils/detecteur',
102+
permanent: true,
103+
},
104+
{
105+
source: '/contenu/detecteur-co2',
106+
destination: '/outils/detecteur',
102107
permanent: true,
103108
},
104109
{

0 commit comments

Comments
 (0)