1- import mermaid from "https://cdn.jsdelivr.net/npm/ mermaid@11.12.0/+esm " ;
2- import "https://cdn.jsdelivr.net/npm/ docsify@4.13.1/+esm " ;
1+ import mermaid from "mermaid" ;
2+ import "docsify" ;
33
44// @ts -check
55
6- mermaid . initialize ( { startOnLoad : false } ) ;
7-
86/**
97 * Build a URL to a GitHub resource
108 * @param {string } type The type of resource ('blob' or 'tree')
@@ -18,12 +16,12 @@ const urlFor = (type, path) => `https://github.com/exteditor/ghostbird/${encodeU
1816 * @param {string } url The URL to redirect to
1917 * @returns {string } A Markdown text
2018 */
21- const redirectTo = ( url ) => JSON . stringify ( { redirectTo : url } ) ;
19+ const redirectTo = ( url ) => JSON . stringify ( { redirectTo : url } ) ;
2220
2321/**
2422 * Does redirect if the text is an instruction for it.
2523 * @param {string } text A Markdown text that may contain a redirect instruction
26- * @returns {string } Returns the `text` as-is if it doesn't contain redirect instruction
24+ * @returns {string | undefined } a message if the text is a redirect instruction; `undefined` otherwise
2725 */
2826function tryRedirect ( text ) {
2927 try {
@@ -35,12 +33,20 @@ function tryRedirect(text) {
3533 } catch ( e ) {
3634 console . warn ( "failed to parse the redirect instruction" , e ) ;
3735 }
38- return text ;
36+ return undefined ;
3937}
4038
39+ /**
40+ * Fix some emojis Docsify doesn't recognize
41+ * @param {string } text The Markdown text
42+ * @returns {string } Markdown text processed
43+ */
44+ const fixEmoji = ( text ) => text . replaceAll ( ':nest_with_eggs:' , '\u{1faba}' ) ;
45+
4146/**
4247 * Add a footer to the Markdown text
4348 * @param {string } text The Markdown text
49+ * @param {import('docsify').Docsify } vm Info about the page
4450 * @returns {string } Markdown text with footer added
4551 */
4652const addFooter = ( text , vm ) => `${ text }
@@ -65,15 +71,13 @@ window.$docsify = {
6571 formatUpdated : '{YYYY}-{MM}-{DD}' ,
6672 relativePath : true ,
6773 executeScript : false ,
68- homepage : "homepage.md" ,
6974 coverpage : "coverpage.md" ,
7075 loadNavbar : "navbar.md" ,
7176 mergeNavbar : true ,
7277 auto2top : true ,
7378 maxLevel : 3 ,
7479 themeColor : '#0b9dd6' ,
7580 routes : {
76- '/README' : ( route ) => redirectTo ( urlFor ( 'blob' , `${ route } .md` ) ) ,
7781 '/LICENSE' : ( route ) => redirectTo ( urlFor ( 'blob' , route ) ) ,
7882 '/[-._/a-zA-Z]*[.][a-zA-Z]+$' : ( route ) => redirectTo ( urlFor ( 'blob' , route ) ) ,
7983 '/[-._/a-zA-Z]+/$' : ( route ) => redirectTo ( urlFor ( 'tree' , route ) ) ,
@@ -84,6 +88,7 @@ window.$docsify = {
8488 '/CONTRIBUTING' ,
8589 '/doc/faq' ,
8690 '/doc/faq-architectural' ,
91+ '/doc/design' ,
8792 '/doc/building' ,
8893 '/doc/testing' ,
8994 ] ,
@@ -99,9 +104,17 @@ window.$docsify = {
99104 } ,
100105 plugins : [
101106 ( hook , vm ) => {
102- hook . beforeEach ( ( text ) => tryRedirect ( text ) ) ;
103- hook . beforeEach ( ( text ) => addFooter ( text , vm ) ) ;
107+ hook . beforeEach ( ( text ) =>
108+ tryRedirect ( text ) ??
109+ addFooter ( fixEmoji ( text ) , vm ) ??
110+ text
111+ ) ;
104112 hook . doneEach ( ( ) => mermaid . run ( ) ) ;
105113 } ,
106114 ] ,
107115} ;
116+
117+ mermaid . initialize ( { startOnLoad : false } ) ;
118+
119+ // load the plugin here having the global `$docsify` defined
120+ await import ( "docsify/plugins/search" ) ;
0 commit comments