pages

package
v4.0.0-beta.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

Index

Constants

This section is empty.

Variables

View Source
var CounterConfig = routes.RouteConfig[CounterPageProps]{
	Type:       routes.STATIC,
	HttpMethod: routes.GET,
	Middleware: func(w http.ResponseWriter, r *http.Request) CounterPageProps {
		return nil
	},
	WasmCompression: routes.BROTLI,
	ClientSideState: func() {
		topic := GetCounterTopic()
		count := CreateObservable(0)

		Observe(func() {
			topic.Set(CounterState{Count: count.Get()})
		}, count)

		Observe(func() {
			SetText("counter-value", strconv.Itoa(count.Get()))
		}, count)

		Observe(func() {
			SetText("counter-mirror", strconv.Itoa(count.Get()))
		}, count)

		CreateWasmFunc("increment", func() {
			count.Set(count.Get() + 1)
		})

		CreateWasmFunc("reset", func() {
			count.Set(0)
		})
	},
}
View Source
var DeployConfig = routes.RouteConfig[DeployPageProps]{
	Type:       routes.STATIC,
	HttpMethod: routes.GET,
	Middleware: func(w http.ResponseWriter, r *http.Request) DeployPageProps {
		return nil
	},
	WasmCompression: routes.BROTLI,
	ClientSideState: func() {
		CreateWasmFunc("copyDeploySnippet", func() {
			snippet := GetElementById("deploy-snippet").Get("textContent").String()
			WriteClipboard(snippet)
			SetText("deploy-copy-label", "COPIED ✓")
		})
	},
}
View Source
var HtmxConfig = routes.RouteConfig[HtmxPageProps]{
	Type:       routes.STATIC,
	HttpMethod: routes.GET,
	Middleware: func(w http.ResponseWriter, r *http.Request) HtmxPageProps {
		return nil
	},
}
View Source
var ImagesConfig = routes.RouteConfig[ImagesPageProps]{
	Type:       routes.STATIC,
	HttpMethod: routes.GET,
	Middleware: func(w http.ResponseWriter, r *http.Request) ImagesPageProps {
		return nil
	},
}
View Source
var IndexConfig = routes.RouteConfig[IndexPageProps]{
	Type:       routes.STATIC,
	HttpMethod: routes.GET,
	Middleware: func(w http.ResponseWriter, r *http.Request) IndexPageProps {
		return nil
	},
}

*

  • `IndexConfig` describes how this specific page should behave within the Gothic routing system. *
  • Options include:
  • - `Type`: Controls how the page is rendered:
  • - `STATIC` (default): Renders once and is cached.
  • - `DYNAMIC`: Runs middleware on every request.
  • - `ISR`: Regenerates at intervals you define (good for SEO + performance). *
  • - `HttpMethod`: Optionally define the HTTP method for HTMX to fetch this page (`GET`, `POST`, etc.). *
  • - `Middleware`: A function that receives the request and returns props for the page/component.
  • - For `STATIC`, runs once on first request.
  • - For `DYNAMIC`, runs on every request.
  • - For `ISR`, runs at the interval specified by `RevalidateInSec`. *
  • Cache backend is configured in `main.go` via `gothicRoutes.Setup()`:
  • - `CacheStrategy`: `CACHE_CONTROL_HEADERS` (default), `IN_MEMORY`, `REDIS`, or `LOCAL_FILES`.
  • - `CacheConfig.RedisURL` / `CacheConfig.RedisPassword`: Required for `REDIS`.
  • - `CacheConfig.CacheFilesPath`: Directory for `LOCAL_FILES` (default: `.gothic-cache`).
  • - `CacheConfig.Compression` / `CacheConfig.CompressionMethod`: Enable gzip or brotli compression.
View Source
var McpConfig = routes.RouteConfig[McpPageProps]{
	Type:       routes.STATIC,
	HttpMethod: routes.GET,
	Middleware: func(w http.ResponseWriter, r *http.Request) McpPageProps {
		return nil
	},
	WasmCompression: routes.BROTLI,
	ClientSideState: func() {
		CreateWasmFunc("copyMcpSnippet", func() {
			snippet := GetElementById("mcp-snippet").Get("textContent").String()
			WriteClipboard(snippet)
			SetText("mcp-copy-label", "COPIED ✓")
		})
	},
}
View Source
var PreloadConfig = routes.RouteConfig[PreloadPageProps]{
	Type:       routes.STATIC,
	HttpMethod: routes.GET,
	Middleware: func(w http.ResponseWriter, r *http.Request) PreloadPageProps {
		return nil
	},
}
View Source
var RevalidateConfig = routes.RouteConfig[RevalidateProps]{
	Type:       routes.ISR,
	HttpMethod: routes.GET,
	Middleware: func(w http.ResponseWriter, r *http.Request) RevalidateProps {
		return time.Now()
	},
	RevalidateInSec: 10,
}

*

  • `RevalidateConfig` defines the configuration for this ISR-enabled route. *
  • - `Type`: Set to `ISR` (Incremental Static Regeneration), allowing the page to be statically generated
  • and then revalidated in the background every `RevalidateInSec` seconds.
  • - `HttpMethod`: Sets the HTTP method this page responds to (in this case, GET).
  • - `Middleware`: Runs server-side to generate the props (`RevalidateProps`) for the page.
  • - `RevalidateInSec`: Specifies the revalidation interval in seconds (every 10 seconds). *
  • Cache backend is configured in main.go via gothicRoutes.Setup().
  • Default: CACHE_CONTROL_HEADERS in production, in-memory during development (hot-reload).

Functions

func Counter

func Counter(props CounterPageProps) templ.Component

func Deploy

func Deploy(props DeployPageProps) templ.Component

func Htmx

func Htmx(props HtmxPageProps) templ.Component

func Images

func Images(props ImagesPageProps) templ.Component

func Index

func Index(props IndexPageProps) templ.Component

func Mcp

func Mcp(props McpPageProps) templ.Component

func Preload

func Preload(props PreloadPageProps) templ.Component

func Revalidate

func Revalidate(currentTime RevalidateProps) templ.Component

Types

type CounterPageProps

type CounterPageProps = interface{}

type DeployPageProps

type DeployPageProps = interface{}

type HtmxPageProps

type HtmxPageProps = interface{}

type ImagesPageProps

type ImagesPageProps = interface{}

type IndexPageProps

type IndexPageProps = interface{}

*

  • Define the type of props your page or component will receive. *
  • This type must remain consistent across:
  • - `RouteConfig` (used to configure the route)
  • - `Middleware` (which injects the props)
  • - The page/component itself (as the props input) *
  • In this example, `IndexPageProps` is an empty interface, but you can define any structure that fits your needs.

type McpPageProps

type McpPageProps = interface{}

type PreloadPageProps

type PreloadPageProps = interface{}

type RevalidateProps

type RevalidateProps = time.Time

*

  • `RevalidateProps` defines the data (props) that this page receives from the middleware.
  • In this case, we’re passing a `time.Time` value that will be displayed in the page.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL