feat: internal links widget with counts and suggestions
- E10 golem15-seo-links in the SEO tab after the graph preview (types with a body): inbound and outbound counts from the last finished crawl, the orphan warning, up to 10 pages to link to (Copy address) and 10 that could link here - classes/linkgraph.go builds the report from the crawl's pages and links; the crawler's orphan suggestions share NormalText - GET /_seo/api/v1/links and seo_get_link_suggestions; widget action seo_links mapped in AdminOperations - element bundle rebuilt
This commit is contained in:
@@ -235,10 +235,32 @@ fields:
|
||||
tab: golem15.seo::lang.tab.seo
|
||||
`
|
||||
|
||||
// seoLinksYAML is E10, the internal links widget (UI-SPEC C16, C19).
|
||||
const seoLinksYAML = ` seo_links:
|
||||
label: golem15.seo::lang.field.links
|
||||
type: widget
|
||||
widget: golem15-seo-links
|
||||
action: seo_links
|
||||
span: full
|
||||
context: update
|
||||
tab: golem15.seo::lang.tab.seo
|
||||
`
|
||||
|
||||
// hasBody reports whether records of a content type of kind have a body
|
||||
// to add links to (UI-SPEC C16 row 14): collections and profiles do not,
|
||||
// nor do the registry's pages, which the site renders itself.
|
||||
func hasBody(key, kind string) bool {
|
||||
if key == classes.PageTypeKey {
|
||||
return false
|
||||
}
|
||||
return kind != pact.ContentKindCollection && kind != pact.ContentKindProfile
|
||||
}
|
||||
|
||||
// seoTabFor is the SEO tab's fields document of a content type (UI-SPEC
|
||||
// C16): seoTabYAML with the primary category after seo_robots for article
|
||||
// types (whose records have parents, P33-23), and the structured data
|
||||
// field (E8) and its preview (E9) after seo_og_image.
|
||||
// types (whose records have parents, P33-23), the structured data field
|
||||
// (E8) and its preview (E9) after seo_og_image, then the internal links
|
||||
// widget (E10) for types with a body.
|
||||
func seoTabFor(key, kind string) string {
|
||||
doc := seoTabYAML
|
||||
quoted := strconv.Quote(key)
|
||||
@@ -254,6 +276,10 @@ func seoTabFor(key, kind string) string {
|
||||
seo_og_title:
|
||||
`, 1)
|
||||
}
|
||||
links := ""
|
||||
if hasBody(key, kind) {
|
||||
links = seoLinksYAML
|
||||
}
|
||||
return strings.Replace(doc, " seo_effective:\n", ` seo_schema:
|
||||
label: golem15.seo::lang.field.schema
|
||||
comment: golem15.seo::lang.field.schema_comment
|
||||
@@ -272,7 +298,7 @@ func seoTabFor(key, kind string) string {
|
||||
span: full
|
||||
context: update
|
||||
tab: golem15.seo::lang.tab.seo
|
||||
seo_effective:
|
||||
`+links+` seo_effective:
|
||||
`, 1)
|
||||
}
|
||||
|
||||
@@ -288,6 +314,7 @@ func (p *Plugin) seoTab(key, kind string) *pact.AdminFormExtension {
|
||||
Actions: []pact.AdminAction{
|
||||
classes.RecordSnippetAction(p.Service, key, "golem15.seo::lang.snippet.action", controllers.PermissionManage),
|
||||
classes.RecordGraphAction(p.Service, key, "golem15.seo::lang.graph.action", controllers.PermissionManage),
|
||||
classes.RecordLinksAction(p.Service, key, "golem15.seo::lang.field.links", controllers.PermissionManage),
|
||||
},
|
||||
PartialData: func(ctx context.Context, name string, record any) (any, error) {
|
||||
return p.seoTabPartial(ctx, key, name, record)
|
||||
|
||||
Reference in New Issue
Block a user