Skip to content

Commit 970ee98

Browse files
kodster28thomasgauvin
authored andcommitted
[Changelog] Add lastUpdated from changelog entry date (#24423)
1 parent e8ed9b7 commit 970ee98

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/components/overrides/Head.astro

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,28 @@ if (currentSection) {
3535
let product = await getEntry("products", currentSection);
3636
// if entry for changelog, grab the first product value (which corresponds to the folder the entry is in) and use as the primary "product"
3737
if (currentSection === "changelog") {
38-
const products = frontmatter.products
38+
const products = frontmatter.products;
3939
if (products) {
4040
product = await getEntry("products", products[0]);
4141
}
4242
}
4343
4444
if (product) {
45-
let productMetaName = product.data.meta.title ? product.data.meta.title : "Cloudflare Docs";
45+
let productMetaName = product.data.meta.title
46+
? product.data.meta.title
47+
: "Cloudflare Docs";
4648
4749
if (currentSection === "changelog") {
48-
productMetaName = "Changelog"
50+
productMetaName = "Changelog";
4951
}
5052
5153
const titleIdx = head.findIndex((x) => x.tag === "title");
5254
let title: string;
5355
5456
// Prefer the title set via frontmatter.head.title. If not, grab the regular frontmatter title value.
55-
const existingTitle = head[titleIdx].content ? head[titleIdx].content?.split(
56-
` ${DEFAULT_TITLE_DELIMITER} `,
57-
)[0]: frontmatter.title;
57+
const existingTitle = head[titleIdx].content
58+
? head[titleIdx].content?.split(` ${DEFAULT_TITLE_DELIMITER} `)[0]
59+
: frontmatter.title;
5860
5961
title = `${existingTitle} · ${productMetaName}`;
6062
@@ -128,8 +130,13 @@ if (
128130
129131
if (frontmatter.pcx_content_type) {
130132
["pcx_content_type", "algolia_content_type"].map((name) => {
131-
const contentType = frontmatter.pcx_content_type
132-
const updatedName = contentType ? (contentType.charAt(0).toUpperCase() + contentType.slice(1)).replace("-", " ") : ""
133+
const contentType = frontmatter.pcx_content_type;
134+
const updatedName = contentType
135+
? (contentType.charAt(0).toUpperCase() + contentType.slice(1)).replace(
136+
"-",
137+
" ",
138+
)
139+
: "";
133140
metaTags.push({
134141
name,
135142
content: updatedName,
@@ -217,7 +224,6 @@ metaTags.map((attrs) => {
217224
attrs,
218225
});
219226
});
220-
221227
---
222228

223229
<script src="src/scripts/footnotes.ts"></script>

src/pages/changelog/[...slug].astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const props = {
3636
noindex: note.data.hidden,
3737
chatbot_deprioritize: true,
3838
pcx_content_type: "changelog-entry",
39-
products: note.data.products.map(a => a.id),
39+
products: note.data.products.map((a) => a.id),
40+
lastUpdated: note.data.date,
4041
},
4142
headings,
4243
hideTitle: true,

0 commit comments

Comments
 (0)