Base URL environment variable

This commit is contained in:
Dennis Reimann
2022-12-15 20:09:35 +01:00
parent 6be2db2161
commit 630b36f02d
2 changed files with 8 additions and 3 deletions

View File

@@ -3,8 +3,11 @@ const glob = require('glob')
const { writeFileSync } = require('fs')
const { resolve } = require('path')
const { DEPLOY_PRIME_URL, URL } = process.env
const BASE = DEPLOY_PRIME_URL || URL || 'https://einundzwanzig.space'
const html = glob.sync(resolve(__dirname, '..', `dist/**/*.html`))
const pages = html.map(file => file.replace(/.*\/dist/, 'https://einundzwanzig.space').replace(/index\.html$/, '')).filter(f => !f.endsWith('/kontakt/') && !f.endsWith('/datenschutz/'))
const pages = html.map(file => file.replace(/.*\/dist/, BASE).replace(/index\.html$/, '')).filter(f => !f.endsWith('/kontakt/') && !f.endsWith('/datenschutz/'))
const now = (new Date()).toISOString()
const file = resolve(__dirname, '..', `src/sitemap.pug`)
const rendered = pug.renderFile(file, { pages, now, pretty: true })