Skip to content

Commit eaf5951

Browse files
committed
feat(seo): enable indexing for the home page and centralize robots logic
updates the home page audience to allow search engine discovery of public landing content while maintaining conditional rendering for authenticated users. refactors the robots meta tag generation in the base layout to use a declarative mapping based on the page audience type.
1 parent b222559 commit eaf5951

2 files changed

Lines changed: 40 additions & 27 deletions

File tree

projects/client/src/lib/sections/layout/TraktPage.svelte

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,16 @@
8181
return `${language}_${region.toUpperCase()}`;
8282
});
8383
84-
const isIndexable = $derived(audience === "all" || audience === "public");
84+
const AUDIENCE_ROBOTS: Record<AudienceProps["audience"], string> = {
85+
all: "index, follow",
86+
public: "index, follow",
87+
free: "noindex, nofollow",
88+
vip: "noindex, nofollow",
89+
authenticated: "noindex, nofollow",
90+
director: "noindex, nofollow",
91+
};
92+
93+
const robots = $derived(AUDIENCE_ROBOTS[audience]);
8594
8695
const createWebsiteLd = (url: string) =>
8796
JSON.stringify({
@@ -134,10 +143,7 @@
134143
<svelte:head>
135144
<title>{displayTitle}</title>
136145
<link rel="canonical" href={canonicalUrl} />
137-
<meta
138-
name="robots"
139-
content={isIndexable ? "index, follow" : "noindex, nofollow"}
140-
/>
146+
<meta name="robots" content={robots} />
141147
<meta property="og:site_name" content={websiteName} />
142148
<meta property="og:type" content={ogType} />
143149
<meta property="og:url" content={canonicalUrl} />
Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import { useAuth } from "$lib/features/auth/stores/useAuth";
23
import { useDiscover } from "$lib/features/discover/useDiscover";
34
import * as m from "$lib/features/i18n/messages.ts";
45
import RenderFor from "$lib/guards/RenderFor.svelte";
@@ -17,38 +18,44 @@
1718
1819
// FIXME: move to PersonalHistoryList when Profile also supports discover mode
1920
const { mode } = useDiscover();
21+
const { isAuthorized } = useAuth();
22+
const audience = $derived($isAuthorized ? "authenticated" : "public");
23+
const pageMode = $derived($isAuthorized ? "default" : "content-only");
2024
</script>
2125

2226
<TraktPage
23-
audience="authenticated"
27+
{audience}
2428
image={DEFAULT_SHARE_COVER}
2529
title={m.page_title_home()}
2630
type="home"
31+
mode={pageMode}
2732
>
28-
<TraktPageCoverSetter />
33+
<RenderFor audience="authenticated">
34+
<TraktPageCoverSetter />
2935

30-
<NavbarStateSetter hasFilters>
31-
{#snippet actions()}
32-
<DiscoverToggles />
33-
{/snippet}
34-
</NavbarStateSetter>
36+
<NavbarStateSetter hasFilters>
37+
{#snippet actions()}
38+
<DiscoverToggles />
39+
{/snippet}
40+
</NavbarStateSetter>
3541

36-
<Banner />
37-
<UpNextList intent="continue" />
38-
<UpNextList intent="start" />
39-
<UpcomingList />
40-
<PersonalHistoryList mode={$mode} />
41-
<ActivityList />
42-
</TraktPage>
42+
<Banner />
43+
<UpNextList intent="continue" />
44+
<UpNextList intent="start" />
45+
<UpcomingList />
46+
<PersonalHistoryList mode={$mode} />
47+
<ActivityList />
48+
</RenderFor>
4349

44-
<RenderFor audience="public">
45-
<NavbarStateSetter mode="hidden" />
50+
<RenderFor audience="public">
51+
<NavbarStateSetter mode="hidden" />
4652

47-
<RenderFor audience="public" device={["tablet-sm", "tablet-lg", "desktop"]}>
48-
<Landing />
49-
</RenderFor>
53+
<RenderFor audience="public" device={["tablet-sm", "tablet-lg", "desktop"]}>
54+
<Landing />
55+
</RenderFor>
5056

51-
<RenderFor audience="public" device={["mobile"]}>
52-
<MobileLanding />
57+
<RenderFor audience="public" device={["mobile"]}>
58+
<MobileLanding />
59+
</RenderFor>
5360
</RenderFor>
54-
</RenderFor>
61+
</TraktPage>

0 commit comments

Comments
 (0)