From 3accdcf4de04b1522ab222c110edbd15d186edf0 Mon Sep 17 00:00:00 2001 From: Roman Kashitsyn Date: Mon, 20 May 2024 14:48:51 +0200 Subject: [PATCH] ui: add support for hackernews links --- blogware/layout.go | 1 + blogware/render.go | 8 ++++++++ blogware/symtab.go | 1 + images/y18.svg | 1 + posts/15-when-rust-hurts.tex | 1 + posts/17-scaling-rust-builds-with-bazel.tex | 1 + posts/25-domain-types.tex | 1 + templates/post-attributes.tmpl | 7 ++++++- 8 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 images/y18.svg diff --git a/blogware/layout.go b/blogware/layout.go index 75e1bcd..01c9c01 100644 --- a/blogware/layout.go +++ b/blogware/layout.go @@ -184,6 +184,7 @@ func renderPostAt(i int, articles []Article) (contents []byte, err error) { Keywords: article.Keywords, URL: article.URL, RedditLink: article.RedditLink, + HNLink: article.HNLink, Similar: findSimilarArticles(articles, i), Toc: toc, Body: body, diff --git a/blogware/render.go b/blogware/render.go index 7122437..19eeacd 100644 --- a/blogware/render.go +++ b/blogware/render.go @@ -33,6 +33,7 @@ type Article struct { Document Env URL string RedditLink string + HNLink string } type PostListRenderContext struct { @@ -55,6 +56,7 @@ type PostRenderContext struct { Keywords []string URL string RedditLink string + HNLink string Toc []TocSection Body template.HTML Similar []Article @@ -146,6 +148,12 @@ func ArticleMetadata(ast []Node) (article Article, err error) { return } article.RedditLink = url + case SymHackernews: + var url string + if err = v.ArgText(0, &url); err != nil { + return + } + article.HNLink = url } case Env: switch v.name { diff --git a/blogware/symtab.go b/blogware/symtab.go index 845bb1c..817fa14 100644 --- a/blogware/symtab.go +++ b/blogware/symtab.go @@ -30,6 +30,7 @@ var ( SymSubSection = BuiltinCmd("subsection", ArgTypeSym, ArgTypeSeq) SymHref = BuiltinCmd("href", ArgTypeURL, ArgTypeSeq) SymReddit = BuiltinCmd("reddit", ArgTypeURL) + SymHackernews = BuiltinCmd("hackernews", ArgTypeURL) SymDocumentClass = BuiltinCmd("documentclass", ArgTypeSym) SymIncludeGraphics = BuiltinCmd("includegraphics", ArgTypeSeq) SymDate = BuiltinCmd("date", ArgTypeSym) diff --git a/images/y18.svg b/images/y18.svg new file mode 100644 index 0000000..faac12a --- /dev/null +++ b/images/y18.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/posts/15-when-rust-hurts.tex b/posts/15-when-rust-hurts.tex index a6877b5..a647f41 100644 --- a/posts/15-when-rust-hurts.tex +++ b/posts/15-when-rust-hurts.tex @@ -3,6 +3,7 @@ \title{When Rust hurts} \subtitle{Why I am not enjoying programming in Rust.} \reddit{https://www.reddit.com/r/rust/comments/112hmga/blog_post_when_rust_hurts/} +\hackernews{https://news.ycombinator.com/item?id=34803379} \date{2023-02-14} \modified{2023-02-16} diff --git a/posts/17-scaling-rust-builds-with-bazel.tex b/posts/17-scaling-rust-builds-with-bazel.tex index 933e1ba..856f64f 100644 --- a/posts/17-scaling-rust-builds-with-bazel.tex +++ b/posts/17-scaling-rust-builds-with-bazel.tex @@ -3,6 +3,7 @@ \title{Scaling Rust builds with Bazel} \subtitle{Why DFINITY builds Rust with Bazel.} \reddit{https://www.reddit.com/r/rust/comments/11xxffc/blog_post_scaling_rust_builds_with_bazel/} +\hackernews{https://news.ycombinator.com/item?id=35270660} \date{2023-03-20} \modified{2023-03-20} diff --git a/posts/25-domain-types.tex b/posts/25-domain-types.tex index a8430c8..064f019 100644 --- a/posts/25-domain-types.tex +++ b/posts/25-domain-types.tex @@ -2,6 +2,7 @@ \title{Universal domain types} \subtitle{A guide to domain-specific types that make sense.} \reddit{https://www.reddit.com/r/types/comments/1b0turi/blog_post_universal_domain_types/} +\hackernews{https://news.ycombinator.com/item?id=39521568} \date{2024-02-26} \modified{2024-02-26} diff --git a/templates/post-attributes.tmpl b/templates/post-attributes.tmpl index 4e59f84..d4a711b 100644 --- a/templates/post-attributes.tmpl +++ b/templates/post-attributes.tmpl @@ -4,11 +4,16 @@   {{ FormatDate .ModifiedAt }} + {{ if .HNLink }} + + Hacker News + + {{- end -}} {{ if .RedditLink }} Reddit - {{- end -}} + {{- end -}} \ No newline at end of file