Skip to content

Commit 37aae6f

Browse files
committed
fix first head issue
1 parent a976b8f commit 37aae6f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/components/ListTutorials.astro

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (!currentProduct) {
1818
);
1919
}
2020
21-
const productTitle = currentProduct.data.product.title;
21+
const productID = currentProduct.id;
2222
2323
const docs = await getCollection("docs", (entry) => {
2424
return (
@@ -27,9 +27,7 @@ const docs = await getCollection("docs", (entry) => {
2727
// /src/content/r2/**/*.mdx
2828
(entry.id.startsWith(`${currentSection}/`) ||
2929
// products: [R2]
30-
entry.data.products?.some(
31-
(v: string) => v.toUpperCase() === productTitle.toUpperCase(),
32-
))
30+
entry.data.products?.some((product) => product.id === productID))
3331
);
3432
});
3533

src/components/overrides/Head.astro

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ const shouldChatbotDeprioritize =
3333
// if not a top-level page, add metadata values from src/content/products/ entries
3434
if (currentSection) {
3535
// if entry for product, grab and proceed
36+
console.log(currentSection);
3637
let product = await getEntry("products", currentSection);
3738
// if entry for changelog, grab the first product value (which corresponds to the folder the entry is in) and use as the primary "product"
3839
if (currentSection === "changelog") {
3940
const products = frontmatter.products;
40-
if (products) {
41-
product = await getEntry("products", products[0]);
41+
if (products && products.length > 0) {
42+
const primaryProduct = products[0];
43+
product = await getEntry("products", primaryProduct.id);
4244
}
4345
}
4446
@@ -112,11 +114,11 @@ if (shouldChatbotDeprioritize) {
112114
if (
113115
frontmatter.description &&
114116
head.findIndex(
115-
({ tag, attrs }) => tag === "meta" && attrs?.name === "description"
117+
({ tag, attrs }) => tag === "meta" && attrs?.name === "description",
116118
) === -1
117119
) {
118120
const existingOpenGraphTag = head.findIndex(
119-
({ tag, attrs }) => tag === "meta" && attrs?.property === "og:description"
121+
({ tag, attrs }) => tag === "meta" && attrs?.property === "og:description",
120122
);
121123
122124
if (existingOpenGraphTag !== -1) {
@@ -166,7 +168,7 @@ if (lastUpdated) {
166168
if (frontmatter.reviewed) {
167169
const daysBetween = differenceInCalendarDays(
168170
new Date(),
169-
frontmatter.reviewed
171+
frontmatter.reviewed,
170172
);
171173
172174
metaTags.push({
@@ -197,7 +199,7 @@ if (frontmatter.pcx_content_type === "changelog") {
197199
198200
const ogImagePath = await getOgImage(
199201
(Astro.locals.starlightRoute.originalEntry as CollectionEntry<"changelog">) ??
200-
Astro.locals.starlightRoute.entry
202+
Astro.locals.starlightRoute.entry,
201203
);
202204
const ogImageUrl = new URL(ogImagePath, Astro.url.origin).toString();
203205

0 commit comments

Comments
 (0)