From c784b062aa0adb141a873b09f427e5018158aaef Mon Sep 17 00:00:00 2001 From: tree Date: Fri, 27 Jan 2023 04:37:17 +0100 Subject: [PATCH] Rework item details --- .../{ => components}/CollectionList.svelte | 12 +- src/lib/components/Footer.svelte | 28 ++++ src/lib/utils.js | 26 ++++ src/routes/[entry]/+page.svelte | 4 +- src/routes/[entry]/[type]/[slug]/+page.svelte | 144 +++++++++++++++--- 5 files changed, 180 insertions(+), 34 deletions(-) rename src/lib/{ => components}/CollectionList.svelte (84%) create mode 100644 src/lib/components/Footer.svelte create mode 100644 src/lib/utils.js diff --git a/src/lib/CollectionList.svelte b/src/lib/components/CollectionList.svelte similarity index 84% rename from src/lib/CollectionList.svelte rename to src/lib/components/CollectionList.svelte index 1fab9534..b042997c 100644 --- a/src/lib/CollectionList.svelte +++ b/src/lib/components/CollectionList.svelte @@ -6,16 +6,8 @@ export let aspect = "aspect-square"; export let size = "normal"; - import { format, addDays } from 'date-fns'; import SvelteMarkdown from 'svelte-markdown'; - - function formateItemDate (item) { - let dt = format(new Date(item.date), "MMMM d") - if (item.days > 1) { - dt += "-" + format(addDays(new Date(item.date), item.days-1), "d") - } - return dt - } + import { formatItemDate } from '$lib/utils.js'; const _url = (col, item) => `/${entry}/${col}/${item.id}` @@ -39,7 +31,7 @@

{item.shortname || item.name}

{#if col === "event"}
- {formateItemDate(item)} + {formatItemDate(item)} {#if item.attendees}
{item.attendees}+ ppl{/if}
{/if} diff --git a/src/lib/components/Footer.svelte b/src/lib/components/Footer.svelte new file mode 100644 index 00000000..01753cf6 --- /dev/null +++ b/src/lib/components/Footer.svelte @@ -0,0 +1,28 @@ + + + +
+
+
⚙ This page is automatically generated using the #PBW23 dataset which can be found at data.prgblockweek.com. +
📖 The source data is hosted in the GitHub repository utxo-foundation/prague-blockchain-week. + Go ahead and do PRs! +
+ {#if item} +
+
+ [{col}:{item.id}]   Show on GitHub + - +
+ {#if showSource} +

JSON source-code

+
{JSON.stringify(item, null, 2)}
+ {/if} +
+ {/if} +
+
\ No newline at end of file diff --git a/src/lib/utils.js b/src/lib/utils.js new file mode 100644 index 00000000..18872f8e --- /dev/null +++ b/src/lib/utils.js @@ -0,0 +1,26 @@ + +import { format, addDays } from 'date-fns'; + +export function formatItemDate (item, opts = {}) { + let dt = format(new Date(item.date), "MMMM d" + (opts.full && item.days === 1 ? ', yyyy' : '')) + if (item.days > 1) { + dt += "-" + format(addDays(new Date(item.date), item.days-1), "d"+ (opts.full ? ', yyyy' : '')) + } + return dt +} + +export function bareDomain (link, type="") { + let out = link.replace(/https?:\/\/(twitter\.com\/|t\.me\/|www\.youtube\.com\/c\/|linkedin\.com\/in\/|www\.|)/g, '').replace(/\/$/, "") + if ([ "twitter", "telegram", "youtube" ].includes(type)) { + out = "@" + out + } + return out +} + +export function getFlagEmoji(countryCode) { + const codePoints = countryCode + .toUpperCase() + .split('') + .map(char => 127397 + char.charCodeAt()); + return String.fromCodePoint(...codePoints); +} \ No newline at end of file diff --git a/src/routes/[entry]/+page.svelte b/src/routes/[entry]/+page.svelte index 47bb30c4..7f151b75 100644 --- a/src/routes/[entry]/+page.svelte +++ b/src/routes/[entry]/+page.svelte @@ -1,5 +1,6 @@ @@ -26,14 +38,106 @@
-
+

#PBW23

+
+
+ {#if item.logo} +
+ {item.name} +
+ {/if} + {#if item.photoUrl} +
+ {item.name} +
+ {/if}
{col.toUpperCase()}
-

{item.name}

+

{item.name}

+ {#if col === 'event'} +
+
+ {#each item.types as type} +
{type}
+ {/each} +
+
{formatItemDate(item, { full: true })}
+
📍 + {#if item.venueUrl} + {item.venueName} + {:else} + {item.venueName} + {/if} +
+ {#if item.attendees} +
👥 {item.attendees}
+ {/if} +
+ {/if} + {#if col === 'speaker'} +
+ +
+
+ {#each Object.keys(speakerLinks) as lk} + {#if speakerLinks[lk].col(item)} + + {/if} + {/each} +
+ {/if}
-
+ + {#if item.desc || item.description} +
+
+
+ {/if} + {#if col === 'event'} +
+
Organizator
+ {#if item.languages} +
+
Languages
+
+ {#each item.languages as lang} +
{getFlagEmoji(langMapper[lang])} {lang}
+ {/each} +
+
+ {/if} + {#if item.chains} +
+
Chains
+
+ {#each item.chains as chain} +
{chain.substr(0, 1).toUpperCase() + chain.substr(1)}
+ {/each} +
+
+ {/if} + {#if item.tags} +
+
Tags
+
+ {#each item.tags as tag} +
#{tag}
+ {/each} +
+
+ {/if} +
+ {/if} + {#if item.links} +
+ {#each Object.keys(item.links) as lk} + + {/each} +
+ {/if} + {#if col === "event"} -

Speakers ({item.speakers?.length || 0})

{#if item.speakers} -
+

Speakers ({item.speakers?.length || 0})

+
- {:else} -
No speakers yet.
{/if} -

Sub-Events ({item.events?.length || 0})

{#if item.events} +

Sub-Events ({item.events?.length || 0})

- {:else} -
No sub-events yet.
{/if} {/if} {#if col === "union"} @@ -105,15 +205,13 @@ data.bundle.events.find(e => e.id === eId))} col="event" img="logo" />
{/if} - -

Source code / Edit

- - {#if showSource} -

JSON source-code

-
{JSON.stringify(item, null, 2)}
+ {#if col === "speaker"} +

Events ({data.bundle.events.filter(e => e.speakers?.find(s => s.id === item.id)).length || 0})

+
+ e.speakers?.find(s => s.id === item.id))} col="event" img="logo" /> +
{/if} + +
\ No newline at end of file