diff --git a/content b/content index 7163548..9cb65b9 160000 --- a/content +++ b/content @@ -1 +1 @@ -Subproject commit 7163548b4acfc83a555242892896c637781ac28d +Subproject commit 9cb65b9ba40365f11a668149e733203e29300a4d diff --git a/public/css/docs-sidebar.css b/public/css/docs-sidebar.css index c24b7fd..ce44650 100644 --- a/public/css/docs-sidebar.css +++ b/public/css/docs-sidebar.css @@ -115,19 +115,15 @@ } /* Responsive design */ @media (max-width: 900px) { - .layout .sidebar { width: 100%; } - } @media (max-width: 768px) { - .layout .sidebar { width: 100%; } - } diff --git a/src/middleware/hbs.js b/src/middleware/hbs.js index 2e805ca..6b20cfa 100644 --- a/src/middleware/hbs.js +++ b/src/middleware/hbs.js @@ -12,26 +12,26 @@ EXTENSION, RUNTIME_OPTIONS, } = require("../constants/hbsConstants"); -const renderObject = (obj) => { - if (typeof obj !== "object" || obj === null) { - return new Handlebars.SafeString(`${String(obj)}`); - } +// const renderObject = (obj) => { +// if (typeof obj !== "object" || obj === null) { +// return new Handlebars.SafeString(`${String(obj)}`); +// } - if (Array.isArray(obj)) { - const items = obj - .map((item) => `
  • ${Handlebars.escapeExpression(String(item))}
  • `) - .join(""); - return new Handlebars.SafeString(``); - } +// if (Array.isArray(obj)) { +// const items = obj +// .map((item) => `
  • ${Handlebars.escapeExpression(String(item))}
  • `) +// .join(""); +// return new Handlebars.SafeString(``); +// } - const entries = Object.entries(obj) - .map(([key, value]) => { - const renderedValue = renderObject(value); - return `
    ${Handlebars.escapeExpression(key)}: ${renderedValue}
    `; - }) - .join(""); - return new Handlebars.SafeString(`
    ${entries}
    `); -}; +// const entries = Object.entries(obj) +// .map(([key, value]) => { +// const renderedValue = renderObject(value); +// return `
    ${Handlebars.escapeExpression(key)}: ${renderedValue}
    `; +// }) +// .join(""); +// return new Handlebars.SafeString(`
    ${entries}
    `); +// }; const hbsMiddleware = (req, res, next) => { if (!req.app.get("view engine")) { @@ -49,7 +49,7 @@ json(context) { return JSON.stringify(context, null, 2); }, - renderObject, + // renderObject, }, extname: EXTENSION, runtimeOptions: RUNTIME_OPTIONS, diff --git a/src/routes/docs.js b/src/routes/docs.js index ffdfc69..0123ce2 100644 --- a/src/routes/docs.js +++ b/src/routes/docs.js @@ -100,6 +100,8 @@ res.render("docs/module", { ...context, + path: docPath, + module, moduleDoc, }); }); @@ -114,13 +116,13 @@ const context = await docsContext(req.isAuthenticated, { layout: "docs", - docPath: null, + docPath: "/docs", docModule: null, }); res.render("docs/index", { ...context, - docsPaths: yamlFiles, + docsPaths: yamlFiles.map((name) => `${req.baseUrl || ""}/${name}`), }); } catch (err) { req.log.error(err.stack); diff --git a/src/utils/hbsHelpers.js b/src/utils/hbsHelpers.js index f591352..097eaf5 100644 --- a/src/utils/hbsHelpers.js +++ b/src/utils/hbsHelpers.js @@ -26,6 +26,13 @@ const dd = String(d.getDate()).padStart(2, "0"); return `${yyyy}-${mm}-${dd}`; }); + hbs.handlebars.registerHelper("isObject", function (value) { + return typeof value === "object" && value !== null && !Array.isArray(value); + }); + + hbs.handlebars.registerHelper("isArray", function (value) { + return Array.isArray(value); + }); } module.exports = { registerHelpers }; diff --git a/src/views/docs/index.handlebars b/src/views/docs/index.handlebars index bd25b1f..f52bedb 100644 --- a/src/views/docs/index.handlebars +++ b/src/views/docs/index.handlebars @@ -1,10 +1,4 @@ {{!-- views/docs/index.hbs --}} -{{#section "styles"}} - -{{/section}} -{{#section "scripts"}} - -{{/section}}

    Documentation Files