with one click
create-page
How to create a new page in the Canzeltly application.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
How to create a new page in the Canzeltly application.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | create-page |
| description | How to create a new page in the Canzeltly application. |
This skill covers the process of adding a new page to the Canzeltly application. Pages in this application are built using Lit components that extend providers for context management.
Pages are organized as follows:
src/client/page.<page-name>.tssrc/client/provider.<provider-name>.ts (provide context to pages)src/client/app.routes.ts and src/shared/type.routes.tssrc/client/app.tsIf your page needs specific context or data loading, create a provider that extends CanzeltlyAbstractProvider or CanzeltlyAppProvider.
Example Provider (src/client/provider.my-page.ts):
import { provide } from "@lit/context";
import { property } from "lit/decorators.js";
import { MyPageContext, myPageContext } from "./context.js";
import { CanzeltlyAbstractProvider } from "./provider.abstract.js";
export abstract class CanzeltlyMyPageProvider extends CanzeltlyAbstractProvider {
@provide({ context: myPageContext })
@property({ attribute: false })
myPageContext: MyPageContext = {
data: null,
status: "idle",
};
override async connectedCallback(): Promise<void> {
super.connectedCallback();
await this.load();
}
async load(): Promise<void> {
// Load your page-specific data here
this.myPageContext = {
data: await fetchMyData(),
status: "loaded",
};
}
}
Create a page component that extends your provider (or CanzeltlyAppProvider for basic pages).
Example Page (src/client/page.my-page.ts):
import { css, html, TemplateResult } from "lit";
import { customElement } from "lit/decorators.js";
import { globalStyles } from "./styles.global.js";
import { CanzeltlyAppProvider } from "./provider.app.js";
@customElement("canzeltly-my-page")
export class CanzeltlyMyPage extends CanzeltlyAppProvider {
static override styles = [
globalStyles,
css`
main {
/* Your page styles */
}
`,
];
override render(): TemplateResult {
return html`
<main>
<h1>My New Page</h1>
<p>Welcome to my page!</p>
</main>
`;
}
}
For pages with route parameters, parse them in the constructor or a property:
import { parseRouteParams } from "../shared/util.route-params.js";
@customElement("canzeltly-example-page")
export class CanzeltlyExamplePage extends CanzeltlyAppProvider {
params = parseRouteParams("/example/:id", window.location.pathname);
override render(): TemplateResult {
return html`
<main>
<h1>Example: ${this.params.id}</h1>
</main>
`;
}
}
Add your new route name to the RouteName enum in src/shared/type.routes.ts:
export const RouteName = z.enum(["home", "example", "my_page", "not_found"]);
Add your route to the routes array in src/client/app.routes.ts:
export const routes = [
{
name: RouteName.enum.home,
path: "/",
},
{
name: RouteName.enum.example,
path: "/example/:id",
},
{
name: RouteName.enum.my_page,
path: "/my-page",
},
];
Add the import to src/client/app.ts:
import "./page.my-page.js";
Add a case for your page in the render() method's switch statement:
switch (this.currentRoute!.name) {
case RouteName.enum.home:
return html`
<canzeltly-home-page></canzeltly-home-page>
`;
case RouteName.enum.example:
return html`
<canzeltly-example-page></canzeltly-example-page>
`;
case RouteName.enum.my_page:
return html`
<canzeltly-my-page></canzeltly-my-page>
`;
default:
return html`
<canzeltly-not-found-page></canzeltly-not-found-page>
`;
}
static/app.css for consistent theming.<a> tags for navigation - the app handles SPA routing automatically.parseRouteParams utility for dynamic routes with parameters.Following the steps above, here's what files you'd create/modify for a new "About" page:
import { css, html, TemplateResult } from "lit";
import { customElement } from "lit/decorators.js";
import { globalStyles } from "./styles.global.js";
import { CanzeltlyAppProvider } from "./provider.app.js";
@customElement("canzeltly-about-page")
export class CanzeltlyAboutPage extends CanzeltlyAppProvider {
static override styles = [
globalStyles,
css`
main {
max-width: 800px;
margin: 0 auto;
padding: var(--size-large);
}
`,
];
override render(): TemplateResult {
return html`
<main>
<h1>About Canzeltly</h1>
<p>This is an example application built with the Zelt Stack.</p>
<a href="/" class="standalone">← Back to Home</a>
</main>
`;
}
}
export const RouteName = z.enum(["home", "example", "about", "not_found"]);
export const routes = [
// ... existing routes
{
name: RouteName.enum.about,
path: "/about",
},
];
import "./page.about.js";
// In render method:
case RouteName.enum.about:
return html`
<canzeltly-about-page></canzeltly-about-page>
`;
Now you can navigate to /about to see your new page!
Create and update instructions, skills, and prompts for GitHub Copilot
Create a new feature
How to create a new type of game object
How to create a new type of affect
How to create a new type of affector
How to create a new event