diff --git a/src/constants/branding.ts b/src/constants/branding.ts
index 8458721b..a99a5a0b 100644
--- a/src/constants/branding.ts
+++ b/src/constants/branding.ts
@@ -2,6 +2,8 @@ export const LOGO_PATH = '/images/petit-meme-logo.png'
export const SITE_NAME = 'Petit Meme'
+export const ADMIN_SITE_NAME = `Admin ${SITE_NAME}`
+
export const SITE_ALTERNATE_NAME = 'Petit Mème'
export const PRODUCTION_SITE_URL = 'https://www.petit-meme.io'
diff --git a/src/helpers/page-title.ts b/src/helpers/page-title.ts
new file mode 100644
index 00000000..c067631d
--- /dev/null
+++ b/src/helpers/page-title.ts
@@ -0,0 +1,5 @@
+import { SITE_NAME } from '~/constants/branding'
+
+export const buildPageTitle = (title: string, siteName = SITE_NAME) => {
+ return `${title} | ${siteName}`
+}
diff --git a/src/lib/seo/__tests__/meta.test.ts b/src/lib/seo/__tests__/meta.test.ts
index 56a885ed..14678b98 100644
--- a/src/lib/seo/__tests__/meta.test.ts
+++ b/src/lib/seo/__tests__/meta.test.ts
@@ -1,7 +1,7 @@
import { afterEach, describe, expect, it } from 'vitest'
import { PUBLISHED_MEME_FAKE } from '~/constants/__tests__/meme.fakes'
import type { MemeWithCategories, MemeWithVideo } from '~/constants/meme'
-import { buildMemeSeo, buildSeo } from '~/lib/seo/meta'
+import { buildAdminPageHead, buildMemeSeo, buildSeo } from '~/lib/seo/meta'
import { buildOgImage } from '~/lib/seo/url'
import { getLocale, type Locale, overwriteGetLocale } from '~/paraglide/runtime'
@@ -158,4 +158,20 @@ describe('the public page tags', () => {
expect(readMeta(meta, 'twitter:title')).toBe('Pricing')
expect(readMeta(meta, 'og:site_name')).toBe('Petit Meme')
})
+
+ it('should lead the page title with what the page holds, the site name last', () => {
+ const { meta } = buildSeo({ title: 'Mister V - On s’en bat les couilles' })
+
+ expect(meta[0]).toStrictEqual({
+ title: 'Mister V - On s’en bat les couilles | Petit Meme'
+ })
+ })
+})
+
+describe('the administration tags', () => {
+ it('should lead the page title with the page, then the administration name', () => {
+ expect(buildAdminPageHead('Catégories')).toStrictEqual({
+ meta: [{ title: 'Catégories | Admin Petit Meme' }]
+ })
+ })
})
diff --git a/src/lib/seo/meta.ts b/src/lib/seo/meta.ts
index 5d2f8d9c..0472927f 100644
--- a/src/lib/seo/meta.ts
+++ b/src/lib/seo/meta.ts
@@ -1,8 +1,9 @@
import type { AnyRouteMatch } from '@tanstack/react-router'
-import { SITE_NAME } from '~/constants/branding'
+import { ADMIN_SITE_NAME, SITE_NAME } from '~/constants/branding'
import type { MemeWithCategories, MemeWithVideo } from '~/constants/meme'
import { OG_IMAGE_HEIGHT, OG_IMAGE_WIDTH } from '~/constants/og'
import { MemeStatus } from '~/db/generated/prisma/enums'
+import { buildPageTitle } from '~/helpers/page-title'
import { buildMemePathname } from '~/helpers/pathname'
import {
buildMemeOgImageUrl,
@@ -24,12 +25,6 @@ const OG_LOCALE_MAP = {
en: 'en_US'
} as const satisfies Record
-const ADMIN_SITE_NAME = `Admin ${SITE_NAME}`
-
-export const buildPageTitle = (title: string, siteName = SITE_NAME) => {
- return `${siteName} - ${title}`
-}
-
export const NOINDEX_NOFOLLOW_META = {
name: 'robots',
content: 'noindex,nofollow'
@@ -78,9 +73,7 @@ export const buildSeo = ({
ogType = 'website'
}: SeoParams): SeoResult => {
const locale = getLocale()
- const titlePrefixed = isAdmin
- ? buildPageTitle(title, ADMIN_SITE_NAME)
- : buildPageTitle(title)
+ const pageTitle = buildPageTitle(title, isAdmin ? ADMIN_SITE_NAME : SITE_NAME)
const canonicalBase = canonicalPathname ?? pathname
const canonicalUrl = buildUrl(canonicalBase, locale)
@@ -89,7 +82,7 @@ export const buildSeo = ({
})
const meta = [
- { title: titlePrefixed },
+ { title: pageTitle },
...(keywords ? [{ name: 'keywords', content: keywords }] : []),
{ name: 'author', content: 'Victor de la Fouchardière' },
{ name: 'twitter:title', content: title },
diff --git a/src/routes/_public__root/memes/$memeId.studio.tsx b/src/routes/_public__root/memes/$memeId.studio.tsx
index 00920d8f..9aa65a8a 100644
--- a/src/routes/_public__root/memes/$memeId.studio.tsx
+++ b/src/routes/_public__root/memes/$memeId.studio.tsx
@@ -5,8 +5,8 @@ import {
useCloseStudio,
usePlaceMemePageBelowStudio
} from '~/components/studio/use-studio-history'
+import { buildPageTitle } from '~/helpers/page-title'
import { toStudioMeme } from '~/helpers/studio-meme'
-import { buildPageTitle } from '~/lib/seo/meta'
import { m } from '~/paraglide/messages'
import { getMemeQueryOpts } from '~/queries/meme'
import { getPremiumSubscriptionQueryOpts } from '~/queries/subscription'
diff --git a/src/routes/_public__root/memes/-components/meme-page.tsx b/src/routes/_public__root/memes/-components/meme-page.tsx
index b8f8963c..fa2f6372 100644
--- a/src/routes/_public__root/memes/-components/meme-page.tsx
+++ b/src/routes/_public__root/memes/-components/meme-page.tsx
@@ -33,6 +33,8 @@ const memeRouteApi = getRouteApi('/_public__root/memes/$memeId')
const LONG_DATE_OPTIONS: Intl.DateTimeFormatOptions = { dateStyle: 'long' }
+const CRAWLER_WORD_BREAK = ' '
+
type WatchedMeme = Awaited>
type MemeMetaProps = {
@@ -128,6 +130,7 @@ const MemeDetails = ({ meme }: MemeDetailsProps) => {
{meme.categories.map(({ category }) => {
return (
+ {CRAWLER_WORD_BREAK}
{
{keywords.map((keyword) => {
return (
+ {CRAWLER_WORD_BREAK}
{
})
})
})
+
+type MemeCategoryLink = MemeWithCategories['categories'][number]
+
+type LinkCategoryParams = {
+ categoryId: string
+ slug: string
+ title: string
+ linkedAt: string
+}
+
+const linkCategory = ({
+ categoryId,
+ slug,
+ title,
+ linkedAt
+}: LinkCategoryParams): MemeCategoryLink => {
+ const createdAt = new Date('2025-01-01T00:00:00Z')
+
+ return {
+ memeId: MEME.id,
+ categoryId,
+ createdAt: new Date(linkedAt),
+ category: {
+ id: categoryId,
+ title,
+ slug,
+ keywords: [],
+ family: null,
+ emoji: null,
+ createdAt,
+ updatedAt: createdAt
+ }
+ }
+}
+
+const ANGRY = linkCategory({
+ categoryId: 'category-b',
+ slug: 'enerve',
+ title: 'Énervé',
+ linkedAt: '2026-01-01T00:00:00Z'
+})
+const SOUND = linkCategory({
+ categoryId: 'category-a',
+ slug: 'son',
+ title: 'Son',
+ linkedAt: '2026-02-01T00:00:00Z'
+})
+const SOUND_LINKED_WITH_ANGRY = { ...SOUND, createdAt: ANGRY.createdAt }
+
+const HOME_CRUMB = {
+ '@type': 'ListItem',
+ position: 1,
+ name: 'Accueil',
+ item: 'https://www.petit-meme.io/'
+}
+const MEME_CRUMB = { '@type': 'ListItem', position: 3, name: 'Meme title' }
+
+describe('meme breadcrumb structured data', () => {
+ it('should send a Meme without a Category through the whole library', async () => {
+ const { buildMemeBreadcrumbNode } = await importMemeJsonLd()
+
+ expect(buildMemeBreadcrumbNode(MEME)).toStrictEqual({
+ '@type': 'BreadcrumbList',
+ itemListElement: [
+ HOME_CRUMB,
+ {
+ '@type': 'ListItem',
+ position: 2,
+ name: 'Tous les mèmes',
+ item: 'https://www.petit-meme.io/memes/category/all'
+ },
+ MEME_CRUMB
+ ]
+ })
+ })
+
+ it('should lead with the Category linked first, whatever order the links arrive in', async () => {
+ const { buildMemeBreadcrumbNode } = await importMemeJsonLd()
+
+ expect(
+ buildMemeBreadcrumbNode({ ...MEME, categories: [SOUND, ANGRY] })
+ ).toStrictEqual({
+ '@type': 'BreadcrumbList',
+ itemListElement: [
+ HOME_CRUMB,
+ {
+ '@type': 'ListItem',
+ position: 2,
+ name: 'Énervé',
+ item: 'https://www.petit-meme.io/memes/category/enerve'
+ },
+ MEME_CRUMB
+ ]
+ })
+ })
+
+ it('should break a tie between Categories linked together by their id', async () => {
+ const { buildMemeBreadcrumbNode } = await importMemeJsonLd()
+
+ expect(
+ buildMemeBreadcrumbNode({
+ ...MEME,
+ categories: [ANGRY, SOUND_LINKED_WITH_ANGRY]
+ }).itemListElement
+ ).toContainEqual({
+ '@type': 'ListItem',
+ position: 2,
+ name: 'Son',
+ item: 'https://www.petit-meme.io/memes/category/son'
+ })
+ })
+})
diff --git a/src/routes/_public__root/memes/-lib/meme-json-ld.ts b/src/routes/_public__root/memes/-lib/meme-json-ld.ts
index ab84e842..bbc8c035 100644
--- a/src/routes/_public__root/memes/-lib/meme-json-ld.ts
+++ b/src/routes/_public__root/memes/-lib/meme-json-ld.ts
@@ -1,4 +1,8 @@
-import type { InteractionCounter, VideoObject } from 'schema-dts'
+import type {
+ BreadcrumbList,
+ InteractionCounter,
+ VideoObject
+} from 'schema-dts'
import { createIsomorphicFn } from '@tanstack/react-start'
import { HLS_MIME_TYPE } from '~/constants/bunny'
import type { MemeWithCategories, MemeWithVideo } from '~/constants/meme'
@@ -75,6 +79,28 @@ export const buildVideoNode = (
}
}
+type MemeCategoryLink = MemeWithCategories['categories'][number]
+
+const findFirstLinkedCategory = (links: readonly MemeCategoryLink[]) => {
+ const [firstLink] = links.toSorted((first, second) => {
+ return (
+ first.createdAt.getTime() - second.createdAt.getTime() ||
+ first.categoryId.localeCompare(second.categoryId)
+ )
+ })
+
+ return firstLink?.category
+}
+
+export const buildMemeBreadcrumbNode = (
+ meme: Pick
+): BreadcrumbList => {
+ return buildBreadcrumbNode([
+ buildCategoryCrumb(findFirstLinkedCategory(meme.categories)),
+ { name: meme.title, pathname: buildMemePathname(meme.id) }
+ ])
+}
+
export const getMemeJsonLd = createIsomorphicFn()
.server(
async (meme: MemeWithVideo & Pick) => {
@@ -82,10 +108,7 @@ export const getMemeJsonLd = createIsomorphicFn()
return serializeJsonLdGraph([
buildVideoNode(meme, crawlerStreamUrl),
- buildBreadcrumbNode([
- buildCategoryCrumb(meme.categories[0]?.category),
- { name: meme.title, pathname: buildMemePathname(meme.id) }
- ])
+ buildMemeBreadcrumbNode(meme)
])
}
)
diff --git a/src/routes/admin/index.tsx b/src/routes/admin/index.tsx
index ccaad190..bc1d0357 100644
--- a/src/routes/admin/index.tsx
+++ b/src/routes/admin/index.tsx
@@ -1,5 +1,6 @@
import { z } from 'zod'
import { createFileRoute } from '@tanstack/react-router'
+import { buildAdminPageHead } from '~/lib/seo/meta'
import { listAdminRecentActivityQueryOpts } from '~/queries/admin/activity'
import { listAdminRecentAuditQueryOpts } from '~/queries/admin/dashboard'
import { DashboardPage } from '~/routes/admin/-components/dashboard/dashboard-page'
@@ -26,8 +27,6 @@ export const Route = createFileRoute('/admin/')({
])
},
head: () => {
- return {
- meta: [{ title: 'Dashboard — Admin' }]
- }
+ return buildAdminPageHead('Dashboard')
}
})
diff --git a/src/routes/admin/services.tsx b/src/routes/admin/services.tsx
index 69d20025..096caceb 100644
--- a/src/routes/admin/services.tsx
+++ b/src/routes/admin/services.tsx
@@ -1,11 +1,10 @@
import { createFileRoute } from '@tanstack/react-router'
+import { buildAdminPageHead } from '~/lib/seo/meta'
import { ServicesPage } from './-components/services/services-page'
export const Route = createFileRoute('/admin/services')({
component: ServicesPage,
head: () => {
- return {
- meta: [{ title: 'Services — Admin' }]
- }
+ return buildAdminPageHead('Services')
}
})
diff --git a/src/routes/offline.ts b/src/routes/offline.ts
index 35d39231..27a936e9 100644
--- a/src/routes/offline.ts
+++ b/src/routes/offline.ts
@@ -4,7 +4,7 @@ import {
VIEWPORT_CONTENT,
WEB_APP_THEME_COLOR
} from '~/constants/pwa'
-import { buildPageTitle } from '~/lib/seo/meta'
+import { buildPageTitle } from '~/helpers/page-title'
import { m } from '~/paraglide/messages'
import {
baseLocale,