@@ -6,121 +6,24 @@ export default function OpenGraph(
66 url : string ;
77 } ,
88) {
9- const formatHtmlForMeta = ( html : string | undefined | null ) : string => {
10- // Handle undefined or null values
11- if ( html === undefined || html === null ) {
12- return "" ;
13- }
14-
15- // Convert <sup> content to Unicode superscript characters
16- let formatted = html . replace ( / < s u p > ( \d + ) < \/ s u p > / g, ( _ , digit ) => {
17- const superscriptMap : Record < string , string > = {
18- "0" : "⁰" ,
19- "1" : "¹" ,
20- "2" : "²" ,
21- "3" : "³" ,
22- "4" : "⁴" ,
23- "5" : "⁵" ,
24- "6" : "⁶" ,
25- "7" : "⁷" ,
26- "8" : "⁸" ,
27- "9" : "⁹" ,
28- } ;
29- return digit . split ( "" ) . map ( ( char : any ) => superscriptMap [ char ] || char )
30- . join (
31- "" ,
32- ) ;
33- } ) ;
34-
35- formatted = formatted . replace ( / < s u p > ( [ a - z A - Z ] + ) < \/ s u p > / g, ( _ , text ) => {
36- const superscriptAlphaMap : Record < string , string > = {
37- "a" : "ᵃ" ,
38- "b" : "ᵇ" ,
39- "c" : "ᶜ" ,
40- "d" : "ᵈ" ,
41- "e" : "ᵉ" ,
42- "f" : "ᶠ" ,
43- "g" : "ᵍ" ,
44- "h" : "ʰ" ,
45- "i" : "ⁱ" ,
46- "j" : "ʲ" ,
47- "k" : "ᵏ" ,
48- "l" : "ˡ" ,
49- "m" : "ᵐ" ,
50- "n" : "ⁿ" ,
51- "o" : "ᵒ" ,
52- "p" : "ᵖ" ,
53- "q" : "ᵠ" , // Change from "Q" to lowercase "ᵠ" as the best available option
54- "r" : "ʳ" ,
55- "s" : "ˢ" ,
56- "t" : "ᵗ" ,
57- "u" : "ᵘ" ,
58- "v" : "ᵛ" ,
59- "w" : "ʷ" ,
60- "x" : "ˣ" ,
61- "y" : "ʸ" ,
62- "z" : "ᶻ" ,
63- "A" : "ᴬ" ,
64- "B" : "ᴮ" ,
65- "C" : "ᶜ" ,
66- "D" : "ᴰ" ,
67- "E" : "ᴱ" ,
68- "F" : "ᶠ" ,
69- "G" : "ᴳ" ,
70- "H" : "ᴴ" ,
71- "I" : "ᴵ" ,
72- "J" : "ᴶ" ,
73- "K" : "ᴷ" ,
74- "L" : "ᴸ" ,
75- "M" : "ᴹ" ,
76- "N" : "ᴺ" ,
77- "O" : "ᴼ" ,
78- "P" : "ᴾ" ,
79- "Q" : "ᵠ" ,
80- "R" : "ᴿ" ,
81- "S" : "ˢ" ,
82- "T" : "ᵀ" ,
83- "U" : "ᵁ" ,
84- "V" : "ⱽ" ,
85- "W" : "ᵂ" ,
86- "X" : "ˣ" ,
87- "Y" : "ʸ" ,
88- "Z" : "ᶻ" ,
89- } ;
90- return text . split ( "" ) . map ( ( char : any ) =>
91- superscriptAlphaMap [ char ] || char
92- )
93- . join ( "" ) ;
94- } ) ;
95-
96- formatted = formatted . replace ( / < s u p > ( [ ^ < ] * ) < \/ s u p > / g, "⁽$1⁾" ) ;
97-
98- return formatted . replace ( / < [ ^ > ] * > / g, "" ) ;
99- } ;
100-
1019 let image ;
10210 if ( section == "api" ) {
10311 image = `/img/og.webp` ;
10412 } else {
10513 image = `${ url } index.png` ;
10614 }
107-
108- // Process both title and description with null safety
109- const formattedTitle = formatHtmlForMeta ( title ) ;
110- const formattedDescription = formatHtmlForMeta ( description ) ;
111-
11215 return (
11316 < >
114- < meta name = "twitter:title" content = { formattedTitle } />
115- < meta name = "twitter:description" content = { formattedDescription } />
17+ < meta name = "twitter:title" content = { title } />
18+ < meta name = "twitter:description" content = { description } />
11619 < meta name = "twitter:image" content = { image } />
117- < meta name = "twitter:image:alt" content = { formattedDescription } />
20+ < meta name = "twitter:image:alt" content = { description } />
11821 < meta name = "twitter:card" content = "summary_large_image" />
11922 < meta name = "twitter:site" content = "@deno_land" />
120- < meta property = "og:title" content = { formattedTitle } />
121- < meta property = "og:description" content = { formattedDescription } />
23+ < meta property = "og:title" content = { title } />
24+ < meta property = "og:description" content = { description } />
12225 < meta property = "og:image" content = { image } />
123- < meta property = "og:image:alt" content = { formattedDescription } />
26+ < meta property = "og:image:alt" content = { description } />
12427 < meta property = "og:type" content = "article" />
12528 < meta property = "og:site_name" content = "Deno" />
12629 < meta property = "og:locale" content = "en_US" />
0 commit comments