mirror of
https://github.com/caddyserver/website.git
synced 2025-04-20 20:16:16 -04:00
docs: Add SPA page for listing modules by their ID
This commit is contained in:
parent
0834562c9b
commit
ca8197d483
14 changed files with 565 additions and 392 deletions
31
src/resources/js/module-docs.js
Normal file
31
src/resources/js/module-docs.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
const moduleDocsPathPrefix = "/docs/modules/";
|
||||
|
||||
var moduleID = window.location.pathname.substr(moduleDocsPathPrefix.length);
|
||||
if (moduleID) {
|
||||
// update page title and load the docs for this module
|
||||
document.title = "Module " + moduleID + " - Caddy Documentation";
|
||||
$.get("/api/docs/module/"+moduleID, function(json) {
|
||||
// wait until the DOM has finished loading before rendering the results
|
||||
$(function() {
|
||||
$('#module-docs-container').show();
|
||||
$('h1').text("Module "+moduleID);
|
||||
beginRendering(json);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// populate the module list
|
||||
$.get("/api/modules", function(moduleList) {
|
||||
// wait until the DOM has finished loading before rendering the results
|
||||
$(function() {
|
||||
$('#module-list-container').show();
|
||||
$table = $('#module-list');
|
||||
for (modID in moduleList) {
|
||||
var doc = moduleList[modID];
|
||||
var $tr = $('<tr/>');
|
||||
$tr.append('<td><a href="./'+modID+'" class="module-link">'+modID+'</a></td>');
|
||||
$tr.append('<td>'+markdown(truncate(doc, 200))+'</td>');
|
||||
$table.append($tr);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue