Skip to content

Commit 0ac6bc1

Browse files
authored
Merge pull request #779 from CodingCatDev/dev
chore: promote dev to main (Google Search Console indexing & schema fixes)
2 parents 1321b50 + f72daf5 commit 0ac6bc1

2 files changed

Lines changed: 38 additions & 12 deletions

File tree

‎apps/site/src/lib/structured-data.ts‎

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
import { absoluteUrl, SITE_NAME } from "./site";
2+
import { youtubeId } from "./youtube";
3+
4+
function cleanDescription(
5+
desc?: string | null,
6+
fallback?: string | null,
7+
): string | undefined {
8+
const trimmed = desc?.trim();
9+
if (trimmed && trimmed.toLowerCase() !== "fix me") {
10+
return trimmed;
11+
}
12+
const fb = fallback?.trim();
13+
return fb && fb.toLowerCase() !== "fix me" ? fb : undefined;
14+
}
215

316
/**
417
* JSON-LD builders, ported from the Next app's lib/structured-data.ts.
@@ -97,7 +110,7 @@ export function articleSchema(
97110
"@type": content.articleType ?? "TechArticle",
98111
"@id": `${url}#article`,
99112
headline: content.title ?? undefined,
100-
description: content.excerpt ?? undefined,
113+
description: cleanDescription(content.excerpt, content.title),
101114
...(content.imageUrl ? { image: content.imageUrl } : {}),
102115
...(content.date ? { datePublished: content.date } : {}),
103116
...(content._updatedAt ? { dateModified: content._updatedAt } : {}),
@@ -204,19 +217,27 @@ export function videoObjectSchema(
204217
durationIso = d;
205218
}
206219

220+
const ytId = youtubeId(video.youtubeUrl);
221+
const resolvedThumb =
222+
video.thumbnailUrl ||
223+
(ytId ? `https://i.ytimg.com/vi/${ytId}/hqdefault.jpg` : undefined);
224+
const embedUrl = ytId
225+
? `https://www.youtube.com/embed/${ytId}`
226+
: video.youtubeUrl
227+
.replace("watch?v=", "embed/")
228+
.replace("youtu.be/", "www.youtube.com/embed/");
229+
207230
return {
208231
"@type": "VideoObject",
209232
"@id": `${url}#video`,
210233
name: video.title ?? undefined,
211-
description: video.description ?? undefined,
212-
...(video.thumbnailUrl ? { thumbnailUrl: [video.thumbnailUrl] } : {}),
234+
description: cleanDescription(video.description, video.title),
235+
...(resolvedThumb ? { thumbnailUrl: [resolvedThumb] } : {}),
213236
...(video.uploadDate ? { uploadDate: video.uploadDate } : {}),
214237
...(durationIso ? { duration: durationIso } : {}),
215238
...(video.transcript ? { transcript: video.transcript } : {}),
216239
contentUrl: video.youtubeUrl,
217-
embedUrl: video.youtubeUrl
218-
.replace("watch?v=", "embed/")
219-
.replace("youtu.be/", "www.youtube.com/embed/"),
240+
embedUrl,
220241
};
221242
}
222243

@@ -326,7 +347,7 @@ export function podcastEpisodeSchema(
326347
"@id": `${url}#episode`,
327348
url,
328349
name: content.title ?? undefined,
329-
description: content.excerpt ?? undefined,
350+
description: cleanDescription(content.excerpt, content.title),
330351
...(content.date ? { datePublished: content.date } : {}),
331352
...(content.imageUrl ? { image: content.imageUrl } : {}),
332353
...(content.season ? { seasonNumber: content.season } : {}),

‎apps/site/src/middleware.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,15 @@ export const onRequest = defineMiddleware(async (context, next) => {
7777
});
7878
}
7979

80-
if (context.locals.sanity.preview.enabled) {
81-
// Not cosmetic: without this a response containing unpublished drafts can
82-
// be written to the edge cache and served to the public.
83-
response.headers.set("Cache-Control", "no-store, private");
80+
if (
81+
context.locals.sanity.preview.enabled ||
82+
origin !== "https://codingcat.dev"
83+
) {
84+
if (context.locals.sanity.preview.enabled) {
85+
// Not cosmetic: without this a response containing unpublished drafts can
86+
// be written to the edge cache and served to the public.
87+
response.headers.set("Cache-Control", "no-store, private");
88+
}
8489
response.headers.set("X-Robots-Tag", "noindex, nofollow");
8590
}
8691

@@ -97,7 +102,7 @@ export const onRequest = defineMiddleware(async (context, next) => {
97102
);
98103

99104
// AIPREF / AI Preference Headers
100-
response.headers.set("Content-Usage", "train-ai=n, search=y");
105+
response.headers.set("Content-Usage", "train-ai=y, search=y");
101106

102107
// Always emit Link headers (RFC 8288) for AI agent discoverability
103108
response.headers.set(

0 commit comments

Comments
 (0)