Keeping summaries in the text?

This commit is contained in:
JP Hastings-Spital 2024-10-16 15:35:32 +01:00
parent 8e2dd5ad7f
commit b97582edf9
4 changed files with 17 additions and 7 deletions

View file

@ -17,6 +17,8 @@ tags:
- tech - tech
- why-not - why-not
--- ---
A curious person implements a chess program in an unlikely place: on your printer.
Im 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! Im 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!
Its 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 Ill definitely be reading the follow up post and trying it out if I can! Its 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 Ill definitely be reading the follow up post and trying it out if I can!

View file

@ -18,6 +18,8 @@ tags:
- economics - economics
- politics - politics
--- ---
Cory Doctorow describes why money feels so _necessary_, and why cryptocurrencies dont.
A very interesting read indeed! Ive not looked into the origins of money before, but Corys explanation of the ideas behind _Debt: The First 5,000 Years_ is extremely thought provoking. It certainly explains why money can feel so… oppressive. A very interesting read indeed! Ive not looked into the origins of money before, but Corys 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 ### Highlights

View file

@ -14,7 +14,7 @@ references:
summary: A wonderful presentation on the limitations of the web, and how to adapt 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! 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 ### Highlights

View file

@ -96,7 +96,7 @@ func outputArticle(article Article, outputDir string) error {
articlePath = dirArticlePath articlePath = dirArticlePath
} }
fm, _ := loadFrontmatter(articlePath) fm, body, _ := loadFrontmatter(articlePath)
hugoPost, err := os.Create(articlePath) hugoPost, err := os.Create(articlePath)
if err != nil { if err != nil {
@ -107,8 +107,13 @@ func outputArticle(article Article, outputDir string) error {
fm.Date = article.BookmarkDate.Format(time.RFC3339) 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 == "" { if fm.Summary == "" {
var summary string
summary, body = shared.ExtractSummary(article.OriginalSummary, body)
fm.Summary = summary fm.Summary = summary
} }
@ -175,20 +180,21 @@ func trimQuote(quote string) string {
return allBold.ReplaceAllString(noTrail, "$1$2") return allBold.ReplaceAllString(noTrail, "$1$2")
} }
func loadFrontmatter(path string) (FrontMatter, error) { func loadFrontmatter(path string) (FrontMatter, string, error) {
f, err := os.Open(path) f, err := os.Open(path)
if err != nil { if err != nil {
return FrontMatter{}, err return FrontMatter{}, "", err
} }
defer f.Close() defer f.Close()
decoder := yaml.NewDecoder(f) decoder := yaml.NewDecoder(f)
var fm FrontMatter var fm FrontMatter
if err := decoder.Decode(&fm); err != nil { 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 { func linkHashtags(text string, tags []string) string {