Skip to content

Commit 403e98d

Browse files
committed
feat: add git always namespace option
1 parent abc8dce commit 403e98d

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

server/modules/storage/git/definition.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ props:
8787
default: './data/repo'
8888
hint: 'Path where the local git repository will be created.'
8989
order: 30
90+
alwaysNamespace:
91+
type: Boolean
92+
title: Always Locale Namespace
93+
default: false
94+
hint: 'Whether to put content from the primary language into a subfolder.'
95+
order: 40
9096
gitBinaryPath:
9197
type: String
9298
title: Git Binary Path

server/modules/storage/git/storage.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ module.exports = {
298298
async created(page) {
299299
WIKI.logger.info(`(STORAGE/GIT) Committing new file [${page.localeCode}] ${page.path}...`)
300300
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
301-
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
301+
if (this.config.alwaysNamespace || (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode)) {
302302
fileName = `${page.localeCode}/${fileName}`
303303
}
304304
const filePath = path.join(this.repoPath, fileName)
@@ -320,7 +320,7 @@ module.exports = {
320320
async updated(page) {
321321
WIKI.logger.info(`(STORAGE/GIT) Committing updated file [${page.localeCode}] ${page.path}...`)
322322
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
323-
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
323+
if (this.config.alwaysNamespace || (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode)) {
324324
fileName = `${page.localeCode}/${fileName}`
325325
}
326326
const filePath = path.join(this.repoPath, fileName)
@@ -342,7 +342,7 @@ module.exports = {
342342
async deleted(page) {
343343
WIKI.logger.info(`(STORAGE/GIT) Committing removed file [${page.localeCode}] ${page.path}...`)
344344
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
345-
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
345+
if (this.config.alwaysNamespace || (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode)) {
346346
fileName = `${page.localeCode}/${fileName}`
347347
}
348348

@@ -364,11 +364,11 @@ module.exports = {
364364
let sourceFileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
365365
let destinationFileName = `${page.destinationPath}.${pageHelper.getFileExtension(page.contentType)}`
366366

367-
if (WIKI.config.lang.namespacing) {
368-
if (WIKI.config.lang.code !== page.localeCode) {
367+
if (this.config.alwaysNamespace || WIKI.config.lang.namespacing) {
368+
if (this.config.alwaysNamespace || WIKI.config.lang.code !== page.localeCode) {
369369
sourceFileName = `${page.localeCode}/${sourceFileName}`
370370
}
371-
if (WIKI.config.lang.code !== page.destinationLocaleCode) {
371+
if (this.config.alwaysNamespace || WIKI.config.lang.code !== page.destinationLocaleCode) {
372372
destinationFileName = `${page.destinationLocaleCode}/${destinationFileName}`
373373
}
374374
}
@@ -483,7 +483,7 @@ module.exports = {
483483
page.tags = await pageObject.$relatedQuery('tags')
484484

485485
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
486-
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
486+
if (this.config.alwaysNamespace || (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode)) {
487487
fileName = `${page.localeCode}/${fileName}`
488488
}
489489
WIKI.logger.info(`(STORAGE/GIT) Adding page ${fileName}...`)

0 commit comments

Comments
 (0)