feat: add links for osm coming events

This commit is contained in:
Tykayn 2023-03-10 13:20:25 +01:00 committed by tykayn
parent b29dbedaf9
commit 5956637cdf

View File

@ -3,7 +3,10 @@ import sendPostMastodon from "./libs/utils.mjs";
import * as coming_events_json from './../assets/documents/agendadulibre_openstreetmap.json' assert { type: "json" };
import {getArticlesFromDaysInJson} from './libs/rss_management.mjs'
import moment from "moment";
let event_date_format = 'dddd DD/MM HH:mm'
let event_date_format_end = 'HH:mm'
const days_filter = 7;
function makeTitleContentFromAgendaDulibre(articles) {
@ -13,11 +16,13 @@ function makeTitleContentFromAgendaDulibre(articles) {
if(! articles.length ){
return '- Aucun évènement prévu. T_T'
}
articles.forEach(item=>{
content += `\n* ${item.city} - ${item.title}` ;
let start = new Date(item.start_time)
let end = new Date(item.end_time)
content += `\n <${start} -- ${end}>` ;
articles.forEach(event=>{
let eventUrl = event.url.replace('.json', '')
let start = moment(new Date(event.start_time)).utcOffset(0).format(event_date_format)
let end = moment(new Date(event.end_time)).utcOffset(0).format(event_date_format_end)
let tags = '#'+event.tags.split(' ').join(' #')
content += `\n* [${event.city} : ${start} - ${end} | ${event.title}](${eventUrl})` ;
content += `\n ${tags}` ;
})
return content;
}