From 9b23eebcbb5e438f2dc6ed0ec056ca8bea488e78 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Wed, 5 Jan 2022 22:04:05 +0200 Subject: [PATCH] feat: talks are linked by their title to the github file (#27) --- __tests__/__snapshots__/main.test.js.snap | 24 +++++++++++------------ __tests__/main.test.js | 3 +++ src/main.js | 8 ++++++++ src/utils/md-formatter.js | 7 ++++++- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/__tests__/__snapshots__/main.test.js.snap b/__tests__/__snapshots__/main.test.js.snap index 1752837..934b983 100644 --- a/__tests__/__snapshots__/main.test.js.snap +++ b/__tests__/__snapshots__/main.test.js.snap @@ -18,9 +18,9 @@ exports[`given a directory of markdown files a full document is rendered 1`] = ` | Date | Event | Title | Slides | Recording | Location | Language | | ---- | ----- | ----- | ------ | --------- | -------- | -------- | -| 2021-7-21 | Cyber Week | Are We Forever Doomed By Software Supply Chain Risks? | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | -| 2021-6-13 | Cyber Week | Are We Forever Doomed By Software Supply Chain Risks? | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | -| 2021-1-1 | Cyber Week | Are We Forever Doomed By Software Supply Chain Risks? | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | +| 2021-7-21 | Cyber Week | [Are We Forever Doomed By Software Supply Chain Risks?](myapp/pages/2021/2021-07-21.md) | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | +| 2021-6-13 | Cyber Week | [Are We Forever Doomed By Software Supply Chain Risks?](myapp/pages/2021/2021-06-13.md) | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | +| 2021-1-1 | Cyber Week | [Are We Forever Doomed By Software Supply Chain Risks?](myapp/pages/2021/2021-01-01.md) | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | # 2019 @@ -31,9 +31,9 @@ exports[`given a directory of markdown files a full document is rendered 1`] = ` | Date | Event | Title | Slides | Recording | Location | Language | | ---- | ----- | ----- | ------ | --------- | -------- | -------- | -| 2019-9-27 | JSConf Budapest | StrangerDanger: Finding Security Vulnerabilities Before They Find You! | | [Recording](https://www.youtube.com/watch?v=3H8pF6yoSgU&list=PL37ZVnwpeshEMCvdYDdZ09Sy-toTftWu0&index=15&ab_channel=JSConf) | HU | English | -| 2019-9-15 | JSConf Budapest | StrangerDanger: Finding Security Vulnerabilities Before They Find You! | | [Recording](https://www.youtube.com/watch?v=3H8pF6yoSgU&list=PL37ZVnwpeshEMCvdYDdZ09Sy-toTftWu0&index=15&ab_channel=JSConf) | HU | English | -| 2019-9-12 | APIdays Barcelona | Consumer-Driven Contracts: A better approach for API Testing | [Slides](https://slides.com/lirantal/consumer-driven-contracts) | [Recording](https://www.youtube.com/watch?v=zfGKX5iKSis&list=PLmEaqnTJ40Oqo9VlbcUakVmFZgx5weLrs&index=25&t=141s&ab_channel=apidays) | ES | English | +| 2019-9-27 | JSConf Budapest | [StrangerDanger: Finding Security Vulnerabilities Before They Find You!](myapp/pages/2019/2019-09-27.md) | | [Recording](https://www.youtube.com/watch?v=3H8pF6yoSgU&list=PL37ZVnwpeshEMCvdYDdZ09Sy-toTftWu0&index=15&ab_channel=JSConf) | HU | English | +| 2019-9-15 | JSConf Budapest | [StrangerDanger: Finding Security Vulnerabilities Before They Find You!](myapp/pages/2019/2019-09-15.md) | | [Recording](https://www.youtube.com/watch?v=3H8pF6yoSgU&list=PL37ZVnwpeshEMCvdYDdZ09Sy-toTftWu0&index=15&ab_channel=JSConf) | HU | English | +| 2019-9-12 | APIdays Barcelona | [Consumer-Driven Contracts: A better approach for API Testing](myapp/pages/2019/2019-09-12.md) | [Slides](https://slides.com/lirantal/consumer-driven-contracts) | [Recording](https://www.youtube.com/watch?v=zfGKX5iKSis&list=PLmEaqnTJ40Oqo9VlbcUakVmFZgx5weLrs&index=25&t=141s&ab_channel=apidays) | ES | English | @@ -63,9 +63,9 @@ Liran Tal | Date | Event | Title | Slides | Recording | Location | Language | | ---- | ----- | ----- | ------ | --------- | -------- | -------- | -| 2021-7-21 | Cyber Week | Are We Forever Doomed By Software Supply Chain Risks? | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | -| 2021-6-13 | Cyber Week | Are We Forever Doomed By Software Supply Chain Risks? | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | -| 2021-1-1 | Cyber Week | Are We Forever Doomed By Software Supply Chain Risks? | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | +| 2021-7-21 | Cyber Week | [Are We Forever Doomed By Software Supply Chain Risks?](myapp/pages/2021/2021-07-21.md) | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | +| 2021-6-13 | Cyber Week | [Are We Forever Doomed By Software Supply Chain Risks?](myapp/pages/2021/2021-06-13.md) | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | +| 2021-1-1 | Cyber Week | [Are We Forever Doomed By Software Supply Chain Risks?](myapp/pages/2021/2021-01-01.md) | | [Recording](https://www.youtube.com/watch?v=x74sMCaZKbg&ab_channel=Snyk) | IL | English | # 2019 @@ -76,9 +76,9 @@ Liran Tal | Date | Event | Title | Slides | Recording | Location | Language | | ---- | ----- | ----- | ------ | --------- | -------- | -------- | -| 2019-9-27 | JSConf Budapest | StrangerDanger: Finding Security Vulnerabilities Before They Find You! | | [Recording](https://www.youtube.com/watch?v=3H8pF6yoSgU&list=PL37ZVnwpeshEMCvdYDdZ09Sy-toTftWu0&index=15&ab_channel=JSConf) | HU | English | -| 2019-9-15 | JSConf Budapest | StrangerDanger: Finding Security Vulnerabilities Before They Find You! | | [Recording](https://www.youtube.com/watch?v=3H8pF6yoSgU&list=PL37ZVnwpeshEMCvdYDdZ09Sy-toTftWu0&index=15&ab_channel=JSConf) | HU | English | -| 2019-9-12 | APIdays Barcelona | Consumer-Driven Contracts: A better approach for API Testing | [Slides](https://slides.com/lirantal/consumer-driven-contracts) | [Recording](https://www.youtube.com/watch?v=zfGKX5iKSis&list=PLmEaqnTJ40Oqo9VlbcUakVmFZgx5weLrs&index=25&t=141s&ab_channel=apidays) | ES | English | +| 2019-9-27 | JSConf Budapest | [StrangerDanger: Finding Security Vulnerabilities Before They Find You!](myapp/pages/2019/2019-09-27.md) | | [Recording](https://www.youtube.com/watch?v=3H8pF6yoSgU&list=PL37ZVnwpeshEMCvdYDdZ09Sy-toTftWu0&index=15&ab_channel=JSConf) | HU | English | +| 2019-9-15 | JSConf Budapest | [StrangerDanger: Finding Security Vulnerabilities Before They Find You!](myapp/pages/2019/2019-09-15.md) | | [Recording](https://www.youtube.com/watch?v=3H8pF6yoSgU&list=PL37ZVnwpeshEMCvdYDdZ09Sy-toTftWu0&index=15&ab_channel=JSConf) | HU | English | +| 2019-9-12 | APIdays Barcelona | [Consumer-Driven Contracts: A better approach for API Testing](myapp/pages/2019/2019-09-12.md) | [Slides](https://slides.com/lirantal/consumer-driven-contracts) | [Recording](https://www.youtube.com/watch?v=zfGKX5iKSis&list=PLmEaqnTJ40Oqo9VlbcUakVmFZgx5weLrs&index=25&t=141s&ab_channel=apidays) | ES | English | diff --git a/__tests__/main.test.js b/__tests__/main.test.js index 1572da7..34db4a1 100644 --- a/__tests__/main.test.js +++ b/__tests__/main.test.js @@ -20,6 +20,9 @@ test('given a directory of markdown files a full document is rendered', async () test('given a directory of markdown files a full document is rendered along with pre and post content', async () => { const filePath = path.join(__dirname, './__fixtures__/main-datafiles') + console.log('---------------------------->') + console.log(filePath) + console.log('---------------------------->') const jsonResult = await generateDocument({ sourceDirectory: filePath, preContent: [ diff --git a/src/main.js b/src/main.js index 89bf30a..eee7524 100644 --- a/src/main.js +++ b/src/main.js @@ -80,6 +80,14 @@ async function generateGigs({ sourceDirectory }) { const entries = [] for (const filePath of allFilesFlatList) { const json = await convertToJson(filePath) + + // push the relative path to the file as part of the data object + let fileDirectoryPath = path.relative(directoryPath, filePath) + if (!path.isAbsolute(sourceDirectory)) { + fileDirectoryPath = path.join(sourceDirectory, fileDirectoryPath) + } + json.fileRelativePath = fileDirectoryPath + entries.push(json) } diff --git a/src/utils/md-formatter.js b/src/utils/md-formatter.js index f9e69ea..5842e10 100644 --- a/src/utils/md-formatter.js +++ b/src/utils/md-formatter.js @@ -1,4 +1,5 @@ import json2md from 'json2md' +import path from 'path' export function formatToMarkdown(data) { return json2md(data) @@ -87,10 +88,14 @@ function eventsListForYear(eventsOfYear) { event.attributes.date.getMonth() + 1 }-${event.attributes.date.getDate()}` + const pathToFileOnGitHub = encodeURI(event.fileRelativePath) + eventsTableEntries.push({ Date: eventDate, Event: event.attributes.name, - Title: event.attributes.title, + Title: event.fileRelativePath + ? `[${event.attributes.title}](${pathToFileOnGitHub})` + : event.attributes.title, Slides: event.attributes.slides_url ? `[Slides](${event.attributes.slides_url})` : '',