datapages-pages
БесплатноБез исполняемых скриптовНе проверенAdd or change a Datapages page: route doc comments, GET return values, path and query parameters, custom error pages, the global head and sharing handlers…
от romshark★ 122 звезды на GitHubОб этом скилле
Pages
Read datapages first for the build loop, hard rules and naming conventions.
Define 1 struct, 1 route doc comment and 1 GET method for each page. PageIndex for / is required. App *App is the only named field a page may declare. Put dependencies on App.
// PageIndex is /
type PageIndex struct{ App *App }
func (PageIndex) GET(r *http.Request) (body datapages.Component, err error) {
return indexPage(), nil
}
Routes use net/http.ServeMux patterns. /item/{id} captures 1 segment. /{path...} captures the remaining path. /{$} matches only that path. Datapages serves a page's SSE stream below _$. Do not define a route that claims that path. A page whose route ends in {$} or {name...} serves only GET: it cannot have actions or an SSE stream. Leave out {$} to give a page actions or a stream: the page keeps its URL.
If a route comment has a description, separate it from the route with a blank // line:
// PageItem is /item/{id}
//
// Shows 1 item.
GET parameters
r *http.Request is required. A GET may also take Session, Path, Query, Signals, datapages.PageCacheWriter and dispatchers. It cannot take datapages.SSE, datapages.State[T] or stateID. See datapages-actions for the parameter types and datapages-offline for pageCache.
GET return values
(body datapages.Component, err error) is the minimum. Add what you need, matched by type:
| type | effect |
|---|---|
datapages.Component |
the body |
datapages.Head |
extra <head> content for this page |
datapages.DocumentAttrs |
attributes of the <html> element by name |
datapages.Redirect |
{URL, Status}, sent instead of the body |
datapages.NewSession[Data] |
opens a session |
datapages.CloseSession |
ends the session |
datapages.EnableBackgroundStreaming |
keep the stream open while the tab is hidden; only a page with a stream may return it |
datapages.DisableRefreshAfterHidden |
no refresh when the tab is shown again; only a page with a stream may return it |
error |
reports an error |
A GETXXX method is a file action, not the page's GET. See
datapages-actions. The page's GET cannot return datapages.File.
Path variables
// PageItem is /item/{id}
func (PageItem) GET(
r *http.Request,
path datapages.Path[struct {
ID string `path:"id"`
}],
) (body datapages.Component, err error) {
return itemPage(path.Values.ID), nil
}
The path tag must match the {...} name in the route exactly.
Query parameters
query datapages.Query[struct {
Term string `query:"t"`
Limit int `query:"l"`
}]
Read values from query.Values. A reflectsignal:"term" tag binds a query field to a Datastar signal. The query parameter sets the initial signal value. Changing the signal rewrites the browser URL. Each segment of the period-separated path must start with a lowercase letter or underscore. Later characters may be letters, digits or underscores. A double underscore is invalid.
A signal change rewrites or removes only its own query parameter. All other parameters remain, including query fields without reflectsignal.
datapages gen rejects duplicate reflectsignal values. Both fields would emit the same data-signals:term attribute, and an HTML parser keeps only the first attribute.
A reflected field must be a basic type or implement encoding.TextMarshaler. A type that only implements encoding.TextUnmarshaler is rejected: it has no text form to seed the signal with.
It also rejects a JSON type mismatch between a query field and its signal. The checked types are number, boolean and string. For example, reflecting a string query field into a bool signal sets $flag to "true". The next action sends {"flag":"true"}, which signal decoding rejects with 400.
Special pages
PageError404, PageError500 and PageOffline are reserved page names. All
3 are optional. Datapages serves defaults when they are absent.
PageError404 renders with status 404 for a URL that no route matches and for a page load whose handler returns datapages.ErrNotFound. PageError500 renders with status 500 for a page load whose handler panics or returns an error without a sentinel.
// PageError404 is /not-found
type PageError404 struct{ App *App }
func (PageError404) GET(r *http.Request) (datapages.Component, error) {
return notFoundPage(), nil
}
PageError500 and PageOffline have the same form and each needs a GET method. PageOffline is the service worker fallback; see datapages-offline. The worker precaches 1 copy for every visitor, so the page renders without the CSRF script and must not depend on who is signed in.
The GET of PageError404 and PageError500 may not return newSession or closeSession because it serves both the page route and the error path. It may accept a session parameter to render the document for the visitor.
Global head
func (*App) Head
Установить datapages-pages в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл datapages-pages?
Add or change a Datapages page: route doc comments, GET return values, path and query parameters, custom error pages, the global head and sharing handlers across pages by embedding.
Как установить скилл datapages-pages?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл datapages-pages запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic