64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
type Bookmark = {
|
|
id: number
|
|
url: string
|
|
title: string
|
|
description: string
|
|
notes: string
|
|
website_title: string | null
|
|
website_description: string | null
|
|
web_archive_snapshot_url: string | null
|
|
is_archived: boolean
|
|
unread: boolean
|
|
shared: boolean
|
|
tag_names: string[]
|
|
date_added: string
|
|
date_modified: string
|
|
}
|
|
|
|
type Response<T> = {
|
|
count: number
|
|
next: string | null
|
|
previous: string | null
|
|
results: T[]
|
|
}
|
|
|
|
const bookmarksRaw: string = await Deno.readTextFile('./content/bookmarks.json')
|
|
const bookmarksResponse = JSON.parse(bookmarksRaw) as Response<Bookmark>
|
|
const bookmarkList = bookmarksResponse.results
|
|
|
|
const templatePrefix = `---
|
|
{
|
|
.title = "Bookmarks",
|
|
.date = @date("2024-07-16T00:00:00"),
|
|
.author = "koehr",
|
|
.draft = false,
|
|
.layout = "page.html",
|
|
.description = "Websites that inspired me, that I think are worth reading, useful and I don't want to forget about.",
|
|
.tags = [],
|
|
}
|
|
---
|
|
|
|
> Check out [The Bukmark Club](https://bukmark.club/) to find more pages featuring a curated collection of bookmarks and/or links to other websites.
|
|
|
|
This page is intended to be generated as part of the build step in the future, but it is not there, yet. Instead it is generated by a small, manually run helper script, therefore the bookmarks might not be fully up to date. For a fully up-to-date version, please refer to my [public bookmark list](https://url.koehr.ing/bookmarks/shared).
|
|
|
|
---
|
|
|
|
`
|
|
|
|
const URL = 'https://url.koehr.ing/bookmarks/shared'
|
|
|
|
const bookmarksMd = bookmarkList.map(bookmark => {
|
|
const { url, title: maybeTitle, description, tag_names: tags, notes } = bookmark
|
|
|
|
const title = maybeTitle?.length > 0 ? maybeTitle : url
|
|
const tagList = tags.map(tag => `[#${tag}](${URL}?q=%23${tag})`).join(' ')
|
|
|
|
return `* [${title}](${url})${description ? ` - ${description}` : ''}
|
|
${tagList}${notes ? `\n\n ${notes}` : ''}
|
|
`
|
|
})
|
|
|
|
console.log(templatePrefix + bookmarksMd.join('\n'))
|
|
|
|
export {}
|