feat(admin): make page extensions configurable
This commit is contained in:
@@ -45,6 +45,10 @@ defaults:
|
||||
company: ''
|
||||
contentLicense: ''
|
||||
logoUrl: https://static.requarks.io/logo/wikijs-butterfly.svg
|
||||
pageExtensions:
|
||||
- md
|
||||
- html
|
||||
- txt
|
||||
mail:
|
||||
host: ''
|
||||
secure: true
|
||||
@@ -152,8 +156,4 @@ reservedPaths:
|
||||
- img
|
||||
- js
|
||||
- svg
|
||||
pageExtensions:
|
||||
- md
|
||||
- html
|
||||
- txt
|
||||
# ---------------------------------
|
||||
|
@@ -414,7 +414,7 @@ router.get('/_userav/:uid', async (req, res, next) => {
|
||||
* View document / asset
|
||||
*/
|
||||
router.get('/*', async (req, res, next) => {
|
||||
const stripExt = _.some(WIKI.data.pageExtensions, ext => _.endsWith(req.path, `.${ext}`))
|
||||
const stripExt = _.some(WIKI.config.pageExtensions, ext => _.endsWith(req.path, `.${ext}`))
|
||||
const pageArgs = pageHelper.parsePath(req.path, { stripExt })
|
||||
const isPage = (stripExt || pageArgs.path.indexOf('.') === -1)
|
||||
|
||||
|
@@ -18,6 +18,7 @@ module.exports = {
|
||||
company: WIKI.config.company,
|
||||
contentLicense: WIKI.config.contentLicense,
|
||||
logoUrl: WIKI.config.logoUrl,
|
||||
pageExtensions: WIKI.config.pageExtensions.join(', '),
|
||||
...WIKI.config.seo,
|
||||
...WIKI.config.features,
|
||||
...WIKI.config.security,
|
||||
@@ -62,6 +63,10 @@ module.exports = {
|
||||
WIKI.config.logoUrl = _.trim(args.logoUrl)
|
||||
}
|
||||
|
||||
if (args.hasOwnProperty('pageExtensions')) {
|
||||
WIKI.config.pageExtensions = _.trim(args.pageExtensions).split(',').map(p => p.trim().toLowerCase()).filter(p => p !== '')
|
||||
}
|
||||
|
||||
WIKI.config.seo = {
|
||||
description: _.get(args, 'description', WIKI.config.seo.description),
|
||||
robots: _.get(args, 'robots', WIKI.config.seo.robots),
|
||||
@@ -104,7 +109,7 @@ module.exports = {
|
||||
forceDownload: _.get(args, 'uploadForceDownload', WIKI.config.uploads.forceDownload)
|
||||
}
|
||||
|
||||
await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'contentLicense', 'seo', 'logoUrl', 'auth', 'features', 'security', 'uploads'])
|
||||
await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'contentLicense', 'seo', 'logoUrl', 'pageExtensions', 'auth', 'features', 'security', 'uploads'])
|
||||
|
||||
if (WIKI.config.security.securityTrustProxy) {
|
||||
WIKI.app.enable('trust proxy')
|
||||
|
@@ -33,6 +33,7 @@ type SiteMutation {
|
||||
company: String
|
||||
contentLicense: String
|
||||
logoUrl: String
|
||||
pageExtensions: String
|
||||
authAutoLogin: Boolean
|
||||
authEnforce2FA: Boolean
|
||||
authHideLocal: Boolean
|
||||
@@ -74,6 +75,7 @@ type SiteConfig {
|
||||
company: String
|
||||
contentLicense: String
|
||||
logoUrl: String
|
||||
pageExtensions: String
|
||||
authAutoLogin: Boolean
|
||||
authEnforce2FA: Boolean
|
||||
authHideLocal: Boolean
|
||||
|
Reference in New Issue
Block a user