GX6007: gx.Head in a widget
The view of a widget, or a component that the view uses, has a gx.Head tag.
Cause
The view of a widget, or a component that the view uses, has a gx.Head tag. gx.Head sets the title and the head of a page. A widget is one element on the page of a host. It has no document, so it has no title and no head.
Example
package cart
props {
Currency string
}
<gx.Head title="Your cart" />
<section>
<p>Your cart in {p.Currency}</p>
</section>package route
import "github.com/alternayte/gx"
type Widget struct {
gx.Route `GET /widgets/cart`
Currency string `query:"currency" default:"EUR"`
}package cart
import (
"github.com/alternayte/gx"
"app/cart/route"
)
var CartWidget = gx.Widget(func(c *gx.Ctx, in route.Widget) (CartProps, error) {
return CartProps{Currency: in.Currency}, nil
}, Cart).Tag("acme-cart")
var Routes = gx.Collect(CartWidget)gx check reports:
cart/Cart.gx:7:1: GX6007: gx.Head is in the widget acme-cart; a widget has no document, so it has no title and no headFix
- Remove
gx.Headfrom the component. Show the text as a heading inside the widget. - When a page of the app also uses the component, put
gx.Headin the view of the page and not in the component.