Add Stuttgart spring fair bookmark links
This commit is contained in:
@@ -613,7 +613,20 @@
|
||||
{
|
||||
rang: 33,
|
||||
messe: 'Stuttgarter Frühjahrsmessen',
|
||||
bookmark_suchbegriffe: ['Stuttgarter Frühjahrsmessen', 'Frühjahrsmessen Stuttgart', 'Fruehjahrsmessen Stuttgart'],
|
||||
bookmark_links: [
|
||||
{ label: 'Stuttgarter Frühjahrsmessen', query: 'Stuttgarter Frühjahrsmessen' },
|
||||
{ label: 'Frühjahrsmessen Stuttgart', query: 'Frühjahrsmessen Stuttgart' },
|
||||
{ label: 'Markt des guten Geschmacks', query: 'Markt des guten Geschmacks Stuttgart' },
|
||||
{ label: 'Fair Handeln', query: 'Fair Handeln Stuttgart' },
|
||||
{ label: 'Garten', query: 'Garten Stuttgart' },
|
||||
{ label: 'BBQ Days', query: 'BBQ Days Stuttgart' },
|
||||
{ label: 'KREATIV', query: 'KREATIV Stuttgart' },
|
||||
{ label: 'Zukunft Haus', query: 'Zukunft Haus Stuttgart' },
|
||||
{ label: 'i-Mobility', query: 'i-Mobility Stuttgart' },
|
||||
{ label: 'Biohacking Days', query: 'Biohacking Days Stuttgart' },
|
||||
{ label: 'YOGAWORLD', query: 'YOGAWORLD Stuttgart' },
|
||||
{ label: 'Babini', query: 'Babini Stuttgart' }
|
||||
],
|
||||
thema: 'Nachhaltigkeit, Genuss, Garten, Mobilitaet, Bauen, Lifestyle',
|
||||
stadt: 'Stuttgart',
|
||||
bundesland: 'Baden-Württemberg',
|
||||
@@ -1574,12 +1587,38 @@
|
||||
}
|
||||
|
||||
function getTradeFairBookmarkQueries(row) {
|
||||
if (Array.isArray(row.bookmark_links) && row.bookmark_links.length) {
|
||||
return [...new Map(
|
||||
row.bookmark_links
|
||||
.map((entry) => {
|
||||
if (!entry) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof entry === 'string') {
|
||||
const trimmed = entry.trim();
|
||||
return trimmed ? { label: trimmed, query: trimmed } : null;
|
||||
}
|
||||
|
||||
const label = String(entry.label || entry.query || '').trim();
|
||||
const query = String(entry.query || entry.label || '').trim();
|
||||
if (!label || !query) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return { label, query };
|
||||
})
|
||||
.filter(Boolean)
|
||||
.map((entry) => [entry.query, entry])
|
||||
).values()];
|
||||
}
|
||||
|
||||
if (Array.isArray(row.bookmark_suchbegriffe) && row.bookmark_suchbegriffe.length) {
|
||||
return [...new Set(
|
||||
row.bookmark_suchbegriffe
|
||||
.map((entry) => String(entry || '').trim())
|
||||
.filter(Boolean)
|
||||
)];
|
||||
)].map((entry) => ({ label: entry, query: entry }));
|
||||
}
|
||||
|
||||
const messe = String(row.messe || '').trim();
|
||||
@@ -1590,11 +1629,11 @@
|
||||
if (messe.includes(' / ')) {
|
||||
const split = messe.split(' / ').map((part) => part.trim()).filter(Boolean);
|
||||
if (split.length > 1) {
|
||||
return [...new Set(split)];
|
||||
return [...new Set(split)].map((entry) => ({ label: entry, query: entry }));
|
||||
}
|
||||
}
|
||||
|
||||
return [messe];
|
||||
return [{ label: messe, query: messe }];
|
||||
}
|
||||
|
||||
function openBookmarkLikeFallback(baseQuery) {
|
||||
@@ -1629,7 +1668,7 @@
|
||||
function openTradeFairSearch(row, explicitBaseQuery) {
|
||||
const baseQuery = explicitBaseQuery
|
||||
? String(explicitBaseQuery).trim()
|
||||
: getTradeFairBookmarkQueries(row)[0];
|
||||
: getTradeFairBookmarkQueries(row)[0]?.query;
|
||||
if (!baseQuery) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1653,8 +1692,8 @@
|
||||
const td = document.createElement('td');
|
||||
td.dataset.column = 'messe';
|
||||
|
||||
const bookmarkQueries = getTradeFairBookmarkQueries(row);
|
||||
if (!bookmarkQueries.length) {
|
||||
const bookmarkLinks = getTradeFairBookmarkQueries(row);
|
||||
if (!bookmarkLinks.length) {
|
||||
td.textContent = row.messe || 'k.A.';
|
||||
return td;
|
||||
}
|
||||
@@ -1662,14 +1701,14 @@
|
||||
const linksWrap = document.createElement('div');
|
||||
linksWrap.className = 'bookmark-subpage__messe-links';
|
||||
|
||||
bookmarkQueries.forEach((query, index) => {
|
||||
bookmarkLinks.forEach((entry, index) => {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'bookmark-subpage__messe-link';
|
||||
button.textContent = query;
|
||||
button.textContent = entry.label;
|
||||
button.title = getTradeFairHoverTitle(row);
|
||||
const handleOpenTradeFair = () => {
|
||||
const opened = openTradeFairSearch(row, query);
|
||||
const opened = openTradeFairSearch(row, entry.query);
|
||||
if (opened > 0) {
|
||||
button.title = getTradeFairHoverTitle(row);
|
||||
render();
|
||||
@@ -1681,7 +1720,7 @@
|
||||
}
|
||||
linksWrap.appendChild(button);
|
||||
|
||||
if (index < bookmarkQueries.length - 1) {
|
||||
if (index < bookmarkLinks.length - 1) {
|
||||
const separator = document.createElement('span');
|
||||
separator.className = 'bookmark-subpage__messe-separator';
|
||||
separator.textContent = ' / ';
|
||||
|
||||
Reference in New Issue
Block a user