-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from MLH-Fellowship/feat/docs-config
Config and Plugin Support
- Loading branch information
Showing
6 changed files
with
139 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"description": "Description", | ||
"plugins": [], | ||
"gaCode": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
// Generates docsify enabled html with no config | ||
function generateHTML(user, repo) { | ||
return `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"/><title>${repo}</title><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/><meta name="description" content="Description"/> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"/> <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css"/> </head> <body> <div id="app"></div><script>window.$docsify={name: '${repo}', repo: '${user}/${repo}'}; </script> <script src="//cdn.jsdelivr.net/npm/docsify@4"></script> </body></html>`; | ||
} | ||
|
||
module.exports = { generateHTML }; | ||
// Generated docsify enabled html with config and plugins | ||
function generateHtmlWithConfig(config) { | ||
let ga = ""; // google analytics code | ||
let search = ""; // search path | ||
|
||
if (config.enablePlugins) { | ||
if (config.plugins.ga) { | ||
ga = `, ga: ${config.gaCode}`; | ||
} | ||
if (config.plugins.search) { | ||
search = ', search: ["/"]'; | ||
} | ||
} | ||
|
||
return `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"/><title>${config.repo}</title><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/><meta name="description" content="${config.description}"/> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"/> <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css"/> </head> <body> <div id="app"></div><script>window.$docsify={name: '${config.repo}', repo: '${config.user}/${config.repo}'${ga}${search}}; </script> <script src="//cdn.jsdelivr.net/npm/docsify@4"></script>${config.plugins.tags}</body></html>`; | ||
} | ||
|
||
module.exports = { generateHTML, generateHtmlWithConfig }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
function addPlugins(pluginList) { | ||
let pluginConfig = { | ||
ga: false, | ||
search: false, | ||
tags: "", | ||
}; | ||
let scriptTags = ""; | ||
for (let i = 0; i < pluginList.length; i++) { | ||
if (pluginList[i] == "docsify-copy-code") { | ||
scriptTags += | ||
"<script src='//cdn.jsdelivr.net/npm/docsify-copy-code'></script>"; | ||
} | ||
if (pluginList[i] == "full-text-search") { | ||
scriptTags += | ||
"<script src='//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js'></script>"; | ||
pluginConfig.search = true; | ||
} | ||
if (pluginList[i] == "google-analytics") { | ||
pluginConfig.ga = true; | ||
} | ||
if (pluginList[i] == "emoji") { | ||
scriptTags += | ||
"<script src='//cdn.jsdelivr.net/npm/docsify/lib/plugins/emoji.min.js'></script>"; | ||
} | ||
if (pluginList[i] == "zoom-image") { | ||
scriptTags += | ||
"<script src='//cdn.jsdelivr.net/npm/docsify/lib/plugins/zoom-image.min.js'></script>"; | ||
} | ||
} | ||
pluginConfig.tags = scriptTags; | ||
return pluginConfig; | ||
} | ||
|
||
module.exports = { addPlugins }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters