feat: the listing names the content types switched off
contract.ListingSettings.TypesOff lists the signpost keys of the content types switched off in the sitemap settings, so another plugin (the SEO tab's sitemap status) can tell an address left out with ReasonType without reading the sitemap's tables. Additive.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"git.golem15.com/golem15/sm-sitemap-plugin/contract"
|
||||
"git.golem15.com/golem15/sm-sitemap-plugin/models"
|
||||
"git.golem15.com/golem15/summercms/modules/backpack"
|
||||
"git.golem15.com/golem15/summercms/modules/signpost"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -42,7 +43,8 @@ func (l Listing) db(ctx context.Context) (*gorm.DB, error) {
|
||||
// locale and the groups with listed addresses (by key), with their titles
|
||||
// (a content type's saved HTML sitemap headings, else the titles of the
|
||||
// published Filter's group of that key), the HTML sitemap settings and the
|
||||
// IndexNow key file name (while IndexNow is on with a key).
|
||||
// IndexNow key file name (while IndexNow is on with a key), and the
|
||||
// content types switched off.
|
||||
func (l Listing) Settings(ctx context.Context) (contract.ListingSettings, error) {
|
||||
var out contract.ListingSettings
|
||||
db, err := l.db(ctx)
|
||||
@@ -77,6 +79,18 @@ func (l Listing) Settings(ctx context.Context) (contract.ListingSettings, error)
|
||||
out.HTMLPaths = settings.EffectiveHTMLPaths()
|
||||
out.HTMLPageSize = settings.EffectiveHTMLPageSize()
|
||||
out.KeyFile = KeyFileName(ActiveKey(settings))
|
||||
out.TypesOff = []string{}
|
||||
if reg, ok := l.App.Lookup[*signpost.Registry](); ok && reg != nil {
|
||||
rows, err := LoadTypeSettings(db)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
for _, typ := range reg.ContentTypes() {
|
||||
if !EffectiveType(typ, rows).Include {
|
||||
out.TypesOff = append(out.TypesOff, typ.Key)
|
||||
}
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user