fix some import/export issue
This commit is contained in:
@@ -96,7 +96,7 @@ const exportController = {
|
|||||||
location: `${e.place.name} - ${e.place.address}`,
|
location: `${e.place.name} - ${e.place.address}`,
|
||||||
url: `${settings.baseurl}/event/${e.slug || e.id}`,
|
url: `${settings.baseurl}/event/${e.slug || e.id}`,
|
||||||
status: 'CONFIRMED',
|
status: 'CONFIRMED',
|
||||||
categories: e.tags.map(t => t.tag),
|
categories: e.tags,
|
||||||
alarms
|
alarms
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const DOMPurify = require('dompurify')
|
|||||||
const { JSDOM } = require('jsdom')
|
const { JSDOM } = require('jsdom')
|
||||||
const { window } = new JSDOM('<!DOCTYPE html>')
|
const { window } = new JSDOM('<!DOCTYPE html>')
|
||||||
const domPurify = DOMPurify(window)
|
const domPurify = DOMPurify(window)
|
||||||
const URL = require('url')
|
const url = require('url')
|
||||||
const locales = require('../locales')
|
const locales = require('../locales')
|
||||||
|
|
||||||
domPurify.addHook('beforeSanitizeElements', node => {
|
domPurify.addHook('beforeSanitizeElements', node => {
|
||||||
@@ -30,7 +30,7 @@ domPurify.addHook('beforeSanitizeElements', node => {
|
|||||||
// remove FB tracking param
|
// remove FB tracking param
|
||||||
if (href.includes('fbclid=')) {
|
if (href.includes('fbclid=')) {
|
||||||
try {
|
try {
|
||||||
const url = new URL.URL(href)
|
const url = new url.URL(href)
|
||||||
url.searchParams.delete('fbclid')
|
url.searchParams.delete('fbclid')
|
||||||
node.setAttribute('href', url.href)
|
node.setAttribute('href', url.href)
|
||||||
if (text.includes('fbclid=')) {
|
if (text.includes('fbclid=')) {
|
||||||
@@ -176,18 +176,21 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
const events = data.items.map(e => {
|
const events = data.items.map(e => {
|
||||||
const props = e.properties
|
const props = e.properties
|
||||||
const media = get(props, 'featured[0]')
|
let media = get(props, 'featured[0]')
|
||||||
|
if (media) {
|
||||||
|
media = url.resolve(URL, media)
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
title: get(props, 'name[0]', ''),
|
title: get(props, 'name[0]', ''),
|
||||||
description: get(props, 'description[0]', ''),
|
description: get(props, 'description[0]', ''),
|
||||||
place: {
|
place: {
|
||||||
name: get(props, 'location[0].properties.name', '') || get(props, 'location[0]'),
|
name: get(props, 'location[0].properties.name[0].value', '') || get(props, 'location[0].properties.name', '') || get(props, 'location[0]'),
|
||||||
address: get(props, 'location[0].properties.street-address')
|
address: get(props, 'location[0].properties.street-address[0]') || get(props, 'location[0].properties.street-address')
|
||||||
},
|
},
|
||||||
start_datetime: dayjs(get(props, 'start[0]', '')).unix(),
|
start_datetime: dayjs(get(props, 'start[0]', '')).unix(),
|
||||||
end_datetime: dayjs(get(props, 'end[0]', '')).unix(),
|
end_datetime: dayjs(get(props, 'end[0]', '')).unix(),
|
||||||
tags: get(props, 'category', []),
|
tags: get(props, 'category', []),
|
||||||
media: media ? [{ name: get(props, 'name[0]', ''), url: get(props, 'featured[0]'), focalpoint: [0, 0] }] : []
|
media: media ? [{ name: get(props, 'name[0]', ''), url: media, focalpoint: [0, 0] }] : []
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return res.json(events)
|
return res.json(events)
|
||||||
@@ -201,9 +204,9 @@ module.exports = {
|
|||||||
return {
|
return {
|
||||||
title: get(event, 'summary', ''),
|
title: get(event, 'summary', ''),
|
||||||
description: get(event, 'description', ''),
|
description: get(event, 'description', ''),
|
||||||
place: get(event, 'location', ''),
|
place: { name: get(event, 'location', '') },
|
||||||
start: get(event, 'dtstart', ''),
|
start_datetime: dayjs(get(event, 'startDate', null)).unix(),
|
||||||
end: get(event, 'dtend', '')
|
end_datetime: dayjs(get(event, 'endDate', null)).unix()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user