cleanup + now topper
This commit is contained in:
parent
6c81b89874
commit
82604bd42b
38 changed files with 123 additions and 8 deletions
40
config/dateFilters.js
Normal file
40
config/dateFilters.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
dateForFeed: (date) => {
|
||||
return new Date(date).toISOString()
|
||||
},
|
||||
toDateTime: (date) => {
|
||||
const formatted = DateTime.fromISO(date)
|
||||
|
||||
const trail = (number) => {
|
||||
return parseInt(number, 10) < 10 ? `0${number}` : number
|
||||
}
|
||||
|
||||
return `${formatted.year}-${trail(formatted.month)}-${trail(formatted.day)} ${trail(
|
||||
formatted.hour
|
||||
)}:${trail(formatted.minute)}`
|
||||
},
|
||||
toDateTimeFromUnix: (date) => {
|
||||
const formatted = DateTime.fromSeconds(parseInt(date, 10))
|
||||
|
||||
const trail = (number) => {
|
||||
return parseInt(number, 10) < 10 ? `0${number}` : number
|
||||
}
|
||||
|
||||
return `${trail(formatted.month)}.${trail(formatted.day)}.${formatted.year} ${trail(
|
||||
formatted.hour
|
||||
)}:${trail(formatted.minute)}`
|
||||
},
|
||||
isoDateOnly: (date) => {
|
||||
let d = new Date(date)
|
||||
let month = '' + (d.getMonth() + 1)
|
||||
let day = '' + d.getDate()
|
||||
let year = d.getFullYear()
|
||||
|
||||
if (month.length < 2) month = '0' + month
|
||||
if (day.length < 2) day = '0' + day
|
||||
|
||||
return [year, month, day].join('-')
|
||||
},
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
const marked = require('marked')
|
||||
const sanitizeHTML = require('sanitize-html')
|
||||
|
||||
module.exports = {
|
||||
|
@ -11,6 +12,9 @@ module.exports = {
|
|||
stripIndex: (path) => {
|
||||
return path.replace('/index.html', '/')
|
||||
},
|
||||
mdToHtml: (content) => {
|
||||
return marked.parse(content)
|
||||
},
|
||||
getFirstAttachment: (post) => {
|
||||
if (post && post.attachments && post.attachments.length > 0) {
|
||||
return post.attachments[0].url ? post.attachments[0].url : post.attachments[0]
|
||||
|
|
Reference in a new issue