prague-blockchain-week/data/23/events/metaverse-festival/_sync.js

40 řádky
1.1 KiB
JavaScript
Surový Normální zobrazení Historie

2023-03-27 04:06:52 +02:00
import { Html5Entities } from "https://deno.land/x/html_entities@v1.0/mod.js";
export async function data(tools) {
const $ = await tools.loadHtmlUrl("https://metaversefestivalprague.com/");
const out = { speakers: [] };
const peopleMapper = {
'Dušan Matuška': { country: 'sk' }
}
for (const el of $("div.elementor-col-16").toArray()) {
const name = cleanupName($('h3 span', el).html())
if (name === "Reveal Soon") {
continue;
}
const item = {
id: tools.formatId(name),
name,
caption: $('p.elementor-icon-box-description', el).text().trim(),
2023-03-27 04:10:35 +02:00
photoUrl: $('div.elementor-widget-container img', el).attr('src'),
2023-03-27 04:06:52 +02:00
}
if (peopleMapper[name]) {
Object.assign(item, peopleMapper[name])
}
out.speakers.push(item);
}
return out;
}
function cleanupName (str) {
return Html5Entities.decode(str.trim())
.replace(/\s?<br>\s?/, ' ')
.toLowerCase()
.split(' ')
.map(str => str.charAt(0).toUpperCase() + str.slice(1))
.join(' ')
}