mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-09 01:35:56 +01:00
Keeping summaries in the text?
This commit is contained in:
parent
8e2dd5ad7f
commit
b97582edf9
4 changed files with 17 additions and 7 deletions
|
@ -17,6 +17,8 @@ tags:
|
|||
- tech
|
||||
- why-not
|
||||
---
|
||||
A curious person implements a chess program in an unlikely place: on your printer.
|
||||
|
||||
I’m always slightly blown away by people who build something because they want to explore and “why not”, rather than for any particular utility. This project is no exception!
|
||||
|
||||
It’s been a while since I files this link away for future me to read, and I now conveniently have a printer to be able to try it on, so I’ll definitely be reading the follow up post and trying it out if I can!
|
||||
|
|
|
@ -18,6 +18,8 @@ tags:
|
|||
- economics
|
||||
- politics
|
||||
---
|
||||
Cory Doctorow describes why money feels so _necessary_, and why cryptocurrencies don’t.
|
||||
|
||||
A very interesting read indeed! I’ve not looked into the origins of money before, but Cory’s explanation of the ideas behind _Debt: The First 5,000 Years_ is extremely thought provoking. It certainly explains why money can feel so… oppressive.
|
||||
|
||||
### Highlights
|
||||
|
|
|
@ -14,7 +14,7 @@ references:
|
|||
summary: A wonderful presentation on the limitations of the web, and how to adapt
|
||||
to them and foster our joy in the web as a medium. I love it!
|
||||
---
|
||||
|
||||
A wonderful presentation on the limitations of the web, and how to adapt to them and foster our joy in the web as a medium. I love it!
|
||||
|
||||
### Highlights
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ func outputArticle(article Article, outputDir string) error {
|
|||
articlePath = dirArticlePath
|
||||
}
|
||||
|
||||
fm, _ := loadFrontmatter(articlePath)
|
||||
fm, body, _ := loadFrontmatter(articlePath)
|
||||
|
||||
hugoPost, err := os.Create(articlePath)
|
||||
if err != nil {
|
||||
|
@ -107,8 +107,13 @@ func outputArticle(article Article, outputDir string) error {
|
|||
fm.Date = article.BookmarkDate.Format(time.RFC3339)
|
||||
}
|
||||
|
||||
summary, body := shared.ExtractSummary(article.OriginalSummary, strings.TrimSpace(article.Annotation))
|
||||
if body == "" {
|
||||
body = strings.TrimSpace(article.Annotation)
|
||||
}
|
||||
|
||||
if fm.Summary == "" {
|
||||
var summary string
|
||||
summary, body = shared.ExtractSummary(article.OriginalSummary, body)
|
||||
fm.Summary = summary
|
||||
}
|
||||
|
||||
|
@ -175,20 +180,21 @@ func trimQuote(quote string) string {
|
|||
return allBold.ReplaceAllString(noTrail, "$1$2")
|
||||
}
|
||||
|
||||
func loadFrontmatter(path string) (FrontMatter, error) {
|
||||
func loadFrontmatter(path string) (FrontMatter, string, error) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return FrontMatter{}, err
|
||||
return FrontMatter{}, "", err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
decoder := yaml.NewDecoder(f)
|
||||
var fm FrontMatter
|
||||
if err := decoder.Decode(&fm); err != nil {
|
||||
return FrontMatter{}, err
|
||||
return FrontMatter{}, "", err
|
||||
}
|
||||
|
||||
return fm, nil
|
||||
rest, err := io.ReadAll(f)
|
||||
return fm, string(rest), err
|
||||
}
|
||||
|
||||
func linkHashtags(text string, tags []string) string {
|
||||
|
|
Loading…
Reference in a new issue