Skip to content

Commit

Permalink
ui: add support for hackernews links
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-kashitsyn committed May 20, 2024
1 parent fcc3526 commit 3accdcf
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions blogware/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions blogware/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Article struct {
Document Env
URL string
RedditLink string
HNLink string
}

type PostListRenderContext struct {
Expand All @@ -55,6 +56,7 @@ type PostRenderContext struct {
Keywords []string
URL string
RedditLink string
HNLink string
Toc []TocSection
Body template.HTML
Similar []Article
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions blogware/symtab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions images/y18.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions posts/15-when-rust-hurts.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
1 change: 1 addition & 0 deletions posts/17-scaling-rust-builds-with-bazel.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
1 change: 1 addition & 0 deletions posts/25-domain-types.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
7 changes: 6 additions & 1 deletion templates/post-attributes.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
 
<span title="Last modified">✂ <span itemprop="dateModified">{{ FormatDate .ModifiedAt }}</span></span>
<span class="post-icons">
{{ if .HNLink }}
<a class="icon-link" href="{{ .HNLink }}" title="Discuss on Hacker News" rel="nofollow" target="_blank">
<img class="y-icon" src="/images/y18.svg" alt="Hacker News" />
</a>
{{- end -}}
{{ if .RedditLink }}
<a class="icon-link" href="{{ .RedditLink }}" title="Discuss on Reddit" rel="nofollow" target="_blank">
<img class="reddit-icon" src="/images/Reddit-Icon.svg" alt="Reddit" />
</a>
</span>
{{- end -}}
</span>
</span>
{{- end -}}

0 comments on commit 3accdcf

Please sign in to comment.