@@ -4,8 +4,6 @@ import he from "he";
44import { remark } from "remark" ;
55import strip from "strip-markdown" ;
66import { rehypeExternalLinksOptions } from "~/plugins/rehype/external-links" ;
7- import { getImage } from "astro:assets" ;
8- import { getEntry , type CollectionEntry } from "astro:content" ;
97
108type TableOfContentsItems = NonNullable < Props [ "toc" ] > [ "items" ] ;
119
@@ -90,56 +88,3 @@ export async function generateDescription({
9088 ?. replaceAll ( rehypeExternalLinksOptions . content . value , "" )
9189 . trim ( ) ;
9290}
93-
94- const DEFAULT_OG_IMAGE = "/cf-twitter-card.png" ;
95-
96- const CHANGELOG_OG_IMAGE = "/changelog-preview.png" ;
97-
98- const PRODUCT_AREA_OG_IMAGES : Record < string , string > = {
99- "cloudflare essentials" : "/core-services-preview.png" ,
100- "cloudflare one" : "/zt-preview.png" ,
101- "developer platform" : "/dev-products-preview.png" ,
102- "network security" : "/core-services-preview.png" ,
103- "application performance" : "/core-services-preview.png" ,
104- "application security" : "/core-services-preview.png" ,
105- } ;
106-
107- export async function getOgImage ( entry : CollectionEntry < "docs" | "changelog" > ) {
108- if ( entry . data . cover ) {
109- if ( ! entry . data . cover . src ) {
110- throw new Error (
111- `${ entry . id } has a cover property in frontmatter that is not a valid image path` ,
112- ) ;
113- }
114-
115- const image = await getImage ( {
116- src : entry . data . cover ,
117- format : "png" ,
118- } ) ;
119-
120- return image . src ;
121- }
122-
123- if ( entry . collection === "changelog" ) {
124- return CHANGELOG_OG_IMAGE ;
125- }
126-
127- const section = entry . id . split ( "/" ) . filter ( Boolean ) . at ( 0 ) ;
128-
129- if ( ! section ) {
130- return DEFAULT_OG_IMAGE ;
131- }
132-
133- const product = await getEntry ( "products" , section ) ;
134-
135- if ( product && product . data . product . group ) {
136- const image =
137- PRODUCT_AREA_OG_IMAGES [ product . data . product . group . toLowerCase ( ) ] ;
138-
139- if ( image ) {
140- return image ;
141- }
142- }
143-
144- return DEFAULT_OG_IMAGE ;
145- }
0 commit comments