mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat(rss): use server title and description for RSS feed, if configured (#4717)
This commit is contained in:
@ -26,6 +26,11 @@ type RSSService struct {
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
type RSSHeading struct {
|
||||
Title string
|
||||
Description string
|
||||
}
|
||||
|
||||
func NewRSSService(profile *profile.Profile, store *store.Store) *RSSService {
|
||||
return &RSSService{
|
||||
Profile: profile,
|
||||
@ -93,10 +98,14 @@ func (s *RSSService) GetUserRSS(c echo.Context) error {
|
||||
}
|
||||
|
||||
func (s *RSSService) generateRSSFromMemoList(ctx context.Context, memoList []*store.Memo, baseURL string) (string, error) {
|
||||
rssHeading, err := getRSSHeading(s.Store, ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
feed := &feeds.Feed{
|
||||
Title: "Memos",
|
||||
Title: rssHeading.Title,
|
||||
Link: &feeds.Link{Href: baseURL},
|
||||
Description: "An open source, lightweight note-taking service. Easily capture and share your great thoughts.",
|
||||
Description: rssHeading.Description,
|
||||
Created: time.Now(),
|
||||
}
|
||||
|
||||
@ -150,3 +159,21 @@ func getRSSItemDescription(content string) (string, error) {
|
||||
result := renderer.NewHTMLRenderer().Render(nodes)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func getRSSHeading(store *store.Store, ctx context.Context) (RSSHeading, error) {
|
||||
settings, err := store.GetWorkspaceGeneralSetting(ctx)
|
||||
if err != nil {
|
||||
return RSSHeading{}, err
|
||||
}
|
||||
if settings == nil || settings.CustomProfile == nil {
|
||||
return RSSHeading{
|
||||
Title: "Memos",
|
||||
Description: "An open source, lightweight note-taking service. Easily capture and share your great thoughts.",
|
||||
}, nil
|
||||
}
|
||||
customProfile := settings.CustomProfile
|
||||
return RSSHeading{
|
||||
Title: customProfile.Title,
|
||||
Description: customProfile.Description,
|
||||
}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user