From f73d5fab56d2a89d24438828a4b57d2b63b875f3 Mon Sep 17 00:00:00 2001 From: Sylvain Gougouzian Date: Sun, 22 Sep 2024 20:45:48 +0200 Subject: [PATCH] fix: :bug: links --- README.md | 21 +++++++++------------ src/DTO.ts | 8 +++++--- src/choc.ts | 2 +- src/render/main.js | 4 ++-- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8b93f32..dc07e6d 100644 --- a/README.md +++ b/README.md @@ -43,18 +43,15 @@ Arguments: json the json export file from Conference Hall Options: - -v, --version output the version number - -c, --with-categories view categories (default: false) - -f, --with-formats view formats (default: false) - -e, --with-companies view speakers company (default: false) - -a, --with-addresses view speakers address (default: false) - -l, --with-languages view talks language (default: false) - -t, --titlelength the title length (default: 100) - -w, --links view links - -x, --export export into tsv file - -r, --render render on a webpage (default: false) - -p, --compact compact render on a webpage (default: false) - -h, --help display help for command + -v, --version output the version number + -c, --with-categories view categories (default: false) + -f, --with-formats view formats (default: false) + -e, --with-companies view speakers company (default: false) + -a, --with-addresses view speakers address (default: false) + -t, --with-languages view talks language (default: false) + -l, --links view links + -p, --compact compact render (default: false) + -h, --help display help for command ``` ### Default usage diff --git a/src/DTO.ts b/src/DTO.ts index 512e111..b3800d8 100644 --- a/src/DTO.ts +++ b/src/DTO.ts @@ -1,6 +1,6 @@ -import type { ConferenceHallTalk, TalkRow } from "./types"; +import type { ConferenceHallTalk, Options, TalkRow } from "./types"; -export const DTO = (talks: ConferenceHallTalk[]): TalkRow[] => +export const DTO = (talks: ConferenceHallTalk[], options: Options): TalkRow[] => talks.map((talk) => ({ id: talk.id, title: talk.title, @@ -20,5 +20,7 @@ export const DTO = (talks: ConferenceHallTalk[]): TalkRow[] => confirmationStatus: talk.confirmationStatus, level: talk.level, languages: talk.languages, - link: `https://conference-hall.io/organizer/event/${Bun.env.EVENTID}/proposals/${talk.id}`, + link: options.links + ? `https://conference-hall.io/organizer/event/${options.links}/proposals/${talk.id}` + : "", })); diff --git a/src/choc.ts b/src/choc.ts index a9b679b..5aee207 100644 --- a/src/choc.ts +++ b/src/choc.ts @@ -6,7 +6,7 @@ import css from "./render/main.css" with { type: "text" }; import type { Options } from "./types.js"; const choc = async (file: string, options: Options) => { - const talks = DTO(await Bun.file(file).json()); + const talks = DTO(await Bun.file(file).json(), options); const server = Bun.serve({ port: 1337, async fetch(req) { diff --git a/src/render/main.js b/src/render/main.js index ca2296a..e97fffe 100644 --- a/src/render/main.js +++ b/src/render/main.js @@ -60,7 +60,7 @@ const joliTalk = (talk) => ` .map((s) => s.company) .join(" ")} ">
- ${linkIcon} + ${talk.link !== "" ? `${linkIcon}` : ""}

${talk.title}

@@ -91,7 +91,7 @@ const rowTalk = (talk) => ` )} " data-companies=" ${talk.speakers .map((s) => s.company) .join(" ")} "> - ${talk.title} + ${talk.link !== "" ? `${linkIcon}` : ""}${talk.title} ${talk.format} ${talk.category} ${talk.speakers.map((s) => s.name).join("
")}