As mentioned in a previous session, creating Dynamic Pages with the Gothic Framework is as simple as adding a route config. The only difference is that you’ll need to change the config type to DYNAMIC. Once this is set, your page will call the Middleware function every time the route is accessed, passing the returned props to the page.
Important note 1: A route config is not required for components and pages, but all page and component functions MUST receive props, even if they are of type any and receive nil as value.
Important note 2: Your page or component must be the first function in your .templ file. If you need to add extra Go functions, please define them below your page or component function.
import routes "github.com/felipegenef/gothicframework/v2/pkg/helpers/routes"
type Props = interface { }
var PageConfig = routes.RouteConfig[ Props ]{
Type: routes.DYNAMIC,
HttpMethod: routes.GET,
Middleware: func (w http.ResponseWriter , r *http.Request ) Props {
return nil
},
}
templ Page ( props Props ) { ... Now that you understand page caching types, learn how to configure the cache system for your entire application!