Skip to content

Commit

Permalink
add localeCode to url
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipinho committed Dec 13, 2023
1 parent e0dfd99 commit 7b492ff
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.env
.env
static/sitemap.xml
2 changes: 1 addition & 1 deletion .env → .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ DB_USER=wikijs
DB_PASS=wikijsrocks
DB_NAME=wiki
DB_SSL=false
PORT=3012
PORT=3012
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.idea
.env
static/sitemap.xml
node_modules
.idea

8 changes: 4 additions & 4 deletions generate-sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ async function generateSitemap() {
.first();

let hostname = '';
if (process.env.DB_TYPE.toLowerCase() === 'mariadb'){
if (process.env.DB_TYPE.toLowerCase() === 'mariadb') {
hostname = JSON.parse(site_url.value).v;
} else {
hostname = site_url.value.v;
}

const pages = await db('pages')
.select('id', 'path', 'title', 'isPrivate', 'isPublished', 'updatedAt')
.select('id', 'localeCode', 'path', 'title', 'isPrivate', 'isPublished', 'updatedAt')
.where({isPrivate: false, isPublished: true});

if (pages.length > 0) {
Expand All @@ -28,7 +28,7 @@ async function generateSitemap() {
'<!-- Wiki.js sitemap generator by https://hostwiki.com -->\n';

pages.forEach(function (page) {
const page_url = hostname + "/" + page.path;
const page_url = hostname + "/" + page.localeCode + "/" + page.path;
const last_update = page.updatedAt;

sitemap += '<url>\n' +
Expand All @@ -48,4 +48,4 @@ async function generateSitemap() {
}
}

module.exports = generateSitemap;
module.exports = generateSitemap;
5 changes: 0 additions & 5 deletions static/sitemap.xml

This file was deleted.

0 comments on commit 7b492ff

Please sign in to comment.