🛠 Podcast and Team pages

This commit is contained in:
Dennis Reimann
2020-10-05 14:51:06 +02:00
parent b2ed9bfb76
commit 7507cd5249
19 changed files with 261 additions and 171 deletions

View File

@@ -3,10 +3,12 @@ const renderMarkdown = require('./markdown')
const slugify = str => str.toLowerCase().replace(/\W/, '-')
const random = max => Math.floor(Math.random() * Math.floor(max))
const shuffle = arr => { for (let i = arr.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * i); const temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; }; return arr }
const formatDate = date => (new Date(date)).toISOString().replace(/T.*/, '').split('-').reverse().join('.')
const linkTarget = url => url.startsWith('http') ? '_blank' : null
const assetPath = path => {
let revs
try { revs = require('./rev-manifest.json') } catch (error) { }
try { revs = require('./generated/rev.json') } catch (error) { }
return `${(revs && revs[path]) || path}`
}
const assetUrl = (path, protocol = 'https') => {
@@ -16,9 +18,11 @@ const assetUrl = (path, protocol = 'https') => {
module.exports = {
basedir: './src/includes',
random,
shuffle,
slugify,
assetUrl,
assetPath,
formatDate,
linkTarget,
renderMarkdown,
}