this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

✨ Add RSS feed

+83 -11
+2
go.mod
··· 44 44 github.com/charmbracelet/bubbletea v0.25.0 // indirect 45 45 github.com/charmbracelet/huh v0.3.0 // indirect 46 46 github.com/charmbracelet/lipgloss v0.10.0 // indirect 47 + github.com/codesoap/rss2 v0.1.0 47 48 github.com/containerd/console v1.0.4 // indirect 48 49 github.com/gabriel-vasile/mimetype v1.4.3 // indirect 49 50 github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect ··· 51 52 github.com/go-git/go-git/v5 v5.12.0 // indirect 52 53 github.com/gomarkdown/markdown v0.0.0-20240328165702-4d01890c35c0 // indirect 53 54 github.com/google/uuid v1.6.0 // indirect 55 + github.com/gorilla/feeds v1.1.2 54 56 github.com/gosuri/uilive v0.0.4 // indirect 55 57 github.com/gosuri/uiprogress v0.0.1 // indirect 56 58 github.com/huandu/xstrings v1.4.0 // indirect
+4
go.sum
··· 46 46 github.com/charmbracelet/huh v0.3.0/go.mod h1:fujUdKX8tC45CCSaRQdw789O6uaCRwx8l2NDyKfC4jA= 47 47 github.com/charmbracelet/lipgloss v0.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMtwg/AFW3s= 48 48 github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE= 49 + github.com/codesoap/rss2 v0.1.0 h1:dl8bitqxsWlOo9ytxXldav8WoCm84TvJqxaqwQVMpkc= 50 + github.com/codesoap/rss2 v0.1.0/go.mod h1:lRA6jsAltY7BBFVVsBw4XYu6l2/74FkqSCPSbTEhyAg= 49 51 github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn4ro= 50 52 github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= 51 53 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= ··· 84 86 github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 85 87 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= 86 88 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 89 + github.com/gorilla/feeds v1.1.2 h1:pxzZ5PD3RJdhFH2FsJJ4x6PqMqbgFk1+Vez4XWBW8Iw= 90 + github.com/gorilla/feeds v1.1.2/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y= 87 91 github.com/gosuri/uilive v0.0.4 h1:hUEBpQDj8D8jXgtCdBu7sWsy5sbW/5GhuO8KBwJ2jyY= 88 92 github.com/gosuri/uilive v0.0.4/go.mod h1:V/epo5LjjlDE5RJUcqx8dbw+zc93y5Ya3yg8tfZ74VI= 89 93 github.com/gosuri/uiprogress v0.0.1 h1:0kpv/XY/qTmFWl/SkaJykZXrBBzwwadmW8fRb7RJSxw=
+23
main.go
··· 122 122 handlePage("blog/"+entry.Slug, pages.BlogEntry(entry, db)) 123 123 } 124 124 125 + feed, err := BlogRssFeed(blogEntries) 126 + if err != nil { 127 + panic(err) 128 + } 129 + server.Handle("/blog/rss.xml", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 130 + w.Header().Set("Content-Type", "application/xml") 131 + content, err := feed.ToRss() 132 + if err != nil { 133 + http.Error(w, "Could not generate RSS feed", http.StatusInternalServerError) 134 + return 135 + } 136 + w.Write([]byte(content)) 137 + })) 138 + server.Handle("/blog/atom.xml", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 139 + w.Header().Set("Content-Type", "application/xml") 140 + content, err := feed.ToAtom() 141 + if err != nil { 142 + http.Error(w, "Could not generate Atom feed", http.StatusInternalServerError) 143 + return 144 + } 145 + w.Write([]byte(content)) 146 + })) 147 + 125 148 for id, collection := range collections { 126 149 handlePage(id, pages.Collection(collection, db, tags, technologies, translations.language)) 127 150 for _, pathname := range collection.Aliases {
+10 -11
pages/blog_index.templ
··· 4 4 import "github.com/ewen-lbh/portfolio/components" 5 5 6 6 templ BlogIndex(entries []shared.BlogEntry) { 7 - @components.IntroWith("Hiya~", "Welcome to my blog index", true) 7 + @components.IntroWith("Hiya~", "Welcome to my blog index", true) { 8 + @components.ArrowLink("/blog/rss.xml") { RSS feed } 9 + @components.ArrowLink("/blog/atom.xml") { Atom feed } 10 + } 8 11 <main class={ articlesList() }> 9 12 <ul class={ components.SkillsList() }> 10 13 for _, entry := range entries { 11 - <li> 12 - @components.Card("/blog/" + entry.Slug) { 13 - <h2>{ entry.Title }</h2> 14 - <p>{ entry.Date.Format("2006-01-02") }</p> 15 - } 16 - // <dt>{ entry.Date.Format("2006-01-02") }</dt> 17 - // <dd> 18 - // <a href={ templ.URL("/blog/" + entry.Slug) }>{ entry.Title }</a> 19 - // </dd> 20 - </li> 14 + <li> 15 + @components.Card("/blog/" + entry.Slug) { 16 + <h2>{ entry.Title }</h2> 17 + <p>{ entry.Date.Format("2006-01-02") }</p> 18 + } 19 + </li> 21 20 } 22 21 </ul> 23 22 </main>
+44
rss.go
··· 1 + package main 2 + 3 + import ( 4 + "github.com/ewen-lbh/portfolio/shared" 5 + "github.com/gorilla/feeds" 6 + ) 7 + 8 + func BlogRssFeed(entries []shared.BlogEntry) (*feeds.Feed, error) { 9 + feed := &feeds.Feed{ 10 + Title: "ewen.works blog", 11 + Link: &feeds.Link{Href: "https://ewen.works/blog"}, 12 + Description: "Blog of Ewen", 13 + Author: &feeds.Author{Name: "Ewen Le Bihan", Email: "hey@ewen.works"}, 14 + Created: earliestEntry(entries...).Date, 15 + } 16 + 17 + for _, entry := range entries { 18 + feed.Items = append(feed.Items, &feeds.Item{ 19 + Title: entry.Title, 20 + Link: &feeds.Link{Href: "https://ewen.works/blog/" + entry.Slug}, 21 + Description: entry.Content, 22 + Author: feed.Author, 23 + Created: entry.Date, 24 + }) 25 + } 26 + 27 + return feed, nil 28 + } 29 + 30 + func earliestEntry(entries ...shared.BlogEntry) *shared.BlogEntry { 31 + if len(entries) == 0 { 32 + return &shared.BlogEntry{} 33 + } 34 + 35 + if len(entries) == 1 { 36 + return &entries[0] 37 + } 38 + 39 + a, b := entries[0], earliestEntry(entries[1:]...) 40 + if a.Date.Before(b.Date) { 41 + return &a 42 + } 43 + return b 44 + }