File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -596,5 +596,38 @@ <h5>Metadata</h5>
596
596
<!-- Bootstrap Bundle JS -->
597
597
< script src ="
https://cdn.jsdelivr.net/npm/[email protected] /dist/js/bootstrap.bundle.min.js "
> </ script >
598
598
< script src ="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js "> </ script >
599
+
600
+
601
+ < script >
602
+ // URL to the hosted emoji.json file
603
+ const gemojiURL = "https://codehimblog.github.io/emoji.json" ;
604
+
605
+ async function replaceEmojis ( ) {
606
+ try {
607
+ // Fetch the Gemoji JSON data
608
+ const response = await fetch ( gemojiURL ) ;
609
+ const emojis = await response . json ( ) ;
610
+
611
+ // Create a map for quick lookup
612
+ const emojiMap = emojis . reduce ( ( map , emoji ) => {
613
+ emoji . names . forEach ( ( name ) => {
614
+ map [ name ] = emoji . emoji ;
615
+ } ) ;
616
+ return map ;
617
+ } , { } ) ;
618
+
619
+ // Replace emoji shortcodes in text
620
+ const contentElement = document . getElementById ( "content" ) ;
621
+ contentElement . innerHTML = contentElement . innerHTML . replace ( / : ( [ a - z A - Z 0 - 9 _ + - ] + ) : / g, ( match , shortcode ) => {
622
+ return emojiMap [ shortcode ] || match ; // Replace or keep original if not found
623
+ } ) ;
624
+ } catch ( error ) {
625
+ console . error ( "Failed to fetch emojis:" , error ) ;
626
+ }
627
+ }
628
+
629
+ // Call the function to replace emojis
630
+ replaceEmojis ( ) ;
631
+ </ script >
599
632
</ body >
600
633
</ html >
You can’t perform that action at this time.
0 commit comments