added an Environment Variable `CMD_DEFAULT_TOC_DEPTH` to set default toc depth

Signed-off-by: Gereon Dusella <git@gereondusella.de>
This commit is contained in:
Gereon Dusella 2020-06-03 17:38:28 +02:00
parent 5847bf09bf
commit 56e01fa76e
5 changed files with 10 additions and 5 deletions

View File

@ -188,5 +188,6 @@ module.exports = {
// 2nd appearance: "31-good-morning-my-friend---do-you-have-5-1" // 2nd appearance: "31-good-morning-my-friend---do-you-have-5-1"
// 3rd appearance: "31-good-morning-my-friend---do-you-have-5-2" // 3rd appearance: "31-good-morning-my-friend---do-you-have-5-2"
linkifyHeaderStyle: 'keep-case', linkifyHeaderStyle: 'keep-case',
autoVersionCheck: true autoVersionCheck: true,
defaultTocDepth: 3
} }

View File

@ -147,5 +147,6 @@ module.exports = {
openID: toBooleanConfig(process.env.CMD_OPENID), openID: toBooleanConfig(process.env.CMD_OPENID),
defaultUseHardbreak: toBooleanConfig(process.env.CMD_DEFAULT_USE_HARD_BREAK), defaultUseHardbreak: toBooleanConfig(process.env.CMD_DEFAULT_USE_HARD_BREAK),
linkifyHeaderStyle: process.env.CMD_LINKIFY_HEADER_STYLE, linkifyHeaderStyle: process.env.CMD_LINKIFY_HEADER_STYLE,
autoVersionCheck: toBooleanConfig(process.env.CMD_AUTO_VERSION_CHECK) autoVersionCheck: toBooleanConfig(process.env.CMD_AUTO_VERSION_CHECK),
defaultTocDepth: toIntegerConfig(process.env.CMD_DEFAULT_TOC_DEPTH)
} }

View File

@ -41,7 +41,8 @@ exports.getConfig = (req, res) => {
allowedUploadMimeTypes: config.allowedUploadMimeTypes, allowedUploadMimeTypes: config.allowedUploadMimeTypes,
defaultUseHardbreak: config.defaultUseHardbreak, defaultUseHardbreak: config.defaultUseHardbreak,
linkifyHeaderStyle: config.linkifyHeaderStyle, linkifyHeaderStyle: config.linkifyHeaderStyle,
useCDN: config.useCDN useCDN: config.useCDN,
defaultTocDepth: config.defaultTocDepth
} }
res.set({ res.set({
'Cache-Control': 'private', // only cache by client 'Cache-Control': 'private', // only cache by client

View File

@ -813,7 +813,7 @@ export function generateToc (id) {
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
var tocOptions = md.meta.toc || {} var tocOptions = md.meta.toc || {}
var maxLevel = (typeof tocOptions.maxLevel === 'number' && tocOptions.maxLevel > 0) ? tocOptions.maxLevel : 3 var maxLevel = (typeof tocOptions.maxLevel === 'number' && tocOptions.maxLevel > 0) ? tocOptions.maxLevel : window.defaultTocDepth
var toc = new window.Toc('doc', { var toc = new window.Toc('doc', {
level: maxLevel, level: maxLevel,
@ -1016,7 +1016,7 @@ export function renderTOC (view) {
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
var tocOptions = md.meta.toc || {} var tocOptions = md.meta.toc || {}
var maxLevel = (typeof tocOptions.maxLevel === 'number' && tocOptions.maxLevel > 0) ? tocOptions.maxLevel : 3 var maxLevel = (typeof tocOptions.maxLevel === 'number' && tocOptions.maxLevel > 0) ? tocOptions.maxLevel : window.defaultTocDepth
const TOC = new window.Toc('doc', { const TOC = new window.Toc('doc', {
level: maxLevel, level: maxLevel,

View File

@ -13,3 +13,5 @@ window.linkifyHeaderStyle = '<%- linkifyHeaderStyle %>'
window.DROPBOX_APP_KEY = '<%- DROPBOX_APP_KEY %>' window.DROPBOX_APP_KEY = '<%- DROPBOX_APP_KEY %>'
window.USE_CDN = <%- useCDN %> window.USE_CDN = <%- useCDN %>
window.defaultTocDepth = <%- defaultTocDepth %>