feat: public API, SEO and existing surfaces
This commit is contained in:
1 parent
45fbbc33b1
commit
c390fcfe8d
103 files changed
+4476
-231
No files matched your search
@@ -29,6 +29,8 @@ type MediaUsage struct {
|
||||
Title string
|
||||
Published *bool
|
||||
Fields []string
|
||||
StoryID *uint32
|
||||
Lang *string
|
||||
|
||||
ContentTypeKey string
|
||||
ContentTypeName string
|
||||
@@ -138,7 +140,8 @@ func usageFor(byID map[uint32]*MediaUsage, found article.Article) *MediaUsage {
|
||||
return entry
|
||||
}
|
||||
published := found.IsOnline
|
||||
entry := &MediaUsage{Type: UsageTypeArticle, ID: found.ID, Title: found.Title, Published: &published, Fields: []string{}}
|
||||
storyID, lang := found.StoryID, found.Lang
|
||||
entry := &MediaUsage{Type: UsageTypeArticle, ID: found.ID, Title: found.Title, Published: &published, Fields: []string{}, StoryID: &storyID, Lang: &lang}
|
||||
byID[found.ID] = entry
|
||||
return entry
|
||||
}
|
||||
@@ -173,3 +176,23 @@ func (u *GetMediaUsageUseCase) siteUsages(img image.Image) ([]MediaUsage, error)
|
||||
func articleMentionsImage(a article.Article, img image.Image) bool {
|
||||
return image.ContainsStoredName(a.Body, image.StoredName(img.Path)) || a.UsesImage(img.ID)
|
||||
}
|
||||
|
||||
type articleGroup struct {
|
||||
story uint32
|
||||
article uint32
|
||||
}
|
||||
|
||||
func groupOf(art article.Article) articleGroup {
|
||||
if art.Lang == "" || art.StoryID == 0 {
|
||||
return articleGroup{article: art.ID}
|
||||
}
|
||||
return articleGroup{story: art.StoryID}
|
||||
}
|
||||
|
||||
func distinctArticleCount(articles []article.Article) int {
|
||||
groups := map[articleGroup]bool{}
|
||||
for _, art := range articles {
|
||||
groups[groupOf(art)] = true
|
||||
}
|
||||
return len(groups)
|
||||
}
|
||||
Reference in new issue
Block a user