@@ -29,38 +29,44 @@ const shouldChatbotDeprioritize =
2929 frontmatter .sidebar .hidden ||
3030 frontmatter .chatbot_deprioritize ;
3131
32+ // if not a top-level page, add metadata values from src/content/products/ entries
3233if (currentSection ) {
33- const product = await getEntry (" products" , currentSection );
34+ // if entry for product, grab and proceed
35+ let product = await getEntry (" products" , currentSection );
36+ // if entry for changelog, grab the first product value (which corresponds to the folder the entry is in) and use as the primary "product"
37+ if (currentSection === " changelog" ) {
38+ const products = frontmatter .products
39+ if (products ) {
40+ product = await getEntry (" products" , products [0 ]);
41+ }
42+ }
3443
3544 if (product ) {
36- if (product .data .meta .title ) {
37- const titleIdx = head .findIndex ((x ) => x .tag === " title" );
45+ let productMetaName = product .data .meta .title ? product .data .meta .title : " Cloudflare Docs" ;
46+
47+ if (currentSection === " changelog" ) {
48+ productMetaName = " Changelog"
49+ }
3850
39- let title: string ;
51+ const titleIdx = head .findIndex ((x ) => x .tag === " title" );
52+ let title: string ;
4053
41- if ( titleIdx !== - 1 ) {
42- const existingTitle = head [titleIdx ].content ?.split (
54+ // 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 (
4356 ` ${DEFAULT_TITLE_DELIMITER } ` ,
44- )[0 ];
45- title = ` ${existingTitle } · ${product .data .meta .title } ` ;
46-
47- head [titleIdx ] = {
48- tag: " title" ,
49- content: title ,
50- };
51- } else {
52- title = ` ${frontmatter .title } · ${product .data .meta .title } ` ;
53- head .push ({
54- tag: " title" ,
55- content: title ,
56- });
57- }
57+ )[0 ]: frontmatter .title ;
5858
59- metaTags .push ({
60- property: " og:title" ,
61- content: title ,
62- });
63- }
59+ title = ` ${existingTitle } · ${productMetaName } ` ;
60+
61+ head [titleIdx ] = {
62+ tag: " title" ,
63+ content: title ,
64+ };
65+
66+ metaTags .push ({
67+ property: " og:title" ,
68+ content: title ,
69+ });
6470
6571 if (product .data .product .title ) {
6672 [" pcx_product" , " algolia_product_filter" ].map ((name ) => {
@@ -122,9 +128,11 @@ if (
122128
123129if (frontmatter .pcx_content_type ) {
124130 [" 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 (" -" , " " ) : " "
125133 metaTags .push ({
126134 name ,
127- content: frontmatter . pcx_content_type as string ,
135+ content: updatedName ,
128136 });
129137 });
130138}
@@ -209,6 +217,7 @@ metaTags.map((attrs) => {
209217 attrs ,
210218 });
211219});
220+
212221---
213222
214223<script src =" src/scripts/footnotes.ts" ></script >
0 commit comments