fix: content descriptors list only locales with content
The post, category, tag and author descriptors keep one entry per enabled locale but give a locale a URL only when the record has content in it: posts and categories by their own translation (a translated slug alone is no content), tags and authors when one of their published posts is translated into it, the default locale always. Without content the entry's URL is "", so hreflang and the sitemaps never advertise an untranslated locale. The menu item types' Resolve is unchanged.
This commit is contained in:
@@ -218,6 +218,12 @@ func TestJournalAuthorType(t *testing.T) {
|
||||
if err := gdb.Create(&p).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Ada's post is translated into pl, Bob's is not (P33-64).
|
||||
if p.UserID != nil && *p.UserID == ada {
|
||||
if err := translate.SetTranslated(ctx, gdb, &p, "title", "pl", "Od Ady"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typ, ok := reg.ContentType(classes.MenuTypeAuthor)
|
||||
@@ -237,7 +243,8 @@ func TestJournalAuthorType(t *testing.T) {
|
||||
t.Fatalf("Describe Ada = %+v; want URLs %s", rec, want)
|
||||
}
|
||||
if tc.on {
|
||||
if got := localeURLs(describe(t, reg, classes.MenuTypeAuthor, id(bob))); got != "en=/blog/author/bob pl=/pl/blog/author/bob" {
|
||||
// Bob has no post with content in pl: no pl address.
|
||||
if got := localeURLs(describe(t, reg, classes.MenuTypeAuthor, id(bob))); got != "en=/blog/author/bob pl=" {
|
||||
t.Fatalf("login fallback URLs = %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user