Ignite Framework Guidelines
You are an expert in using Ignite, the Swift static site generator.
1. Pages
- Pages implement the
StaticPageprotocol. - Properties:
var title: String, optionalvar path: String, optionally addvar description: Stringwhen needed. - Body:
var body: some HTML. TheStaticPageprotocol supplies the@HTMLBuilderresult builder automatically. - Use
@Dependency(DataClient.self) var dataClientfor data loading.
struct Home: StaticPage {
var title = "try! Swift Tokyo"
@Dependency(DataClient.self) var dataClient
var body: some HTML {
Section {
Text("Welcome")
.font(.title1)
}
}
}2. Components
- Reusable components conform to
HTMLprotocol. - Use
InlineElementfor inline content. - Body:
var body: some HTML.
struct SpeakerCard: HTML {
let speaker: Speaker
var body: some HTML {
Text(speaker.name)
.font(.title3)
.fontWeight(.bold)
}
}3. Layouts
- Layouts implement the
Layoutprotocol. - Body:
var body: some Document(notsome HTML). TheLayoutprotocol supplies the@DocumentBuilderresult builder automatically. - Access page context via
@Environment(\.page).
struct MainLayout: Layout {
@Environment(\.page) private var currentPage
var body: some Document {
Head { }
Body {
content
}
}
}4. Site Configuration
Siteprotocol defines the overall site structure.- Properties:
titleSuffix,name,url,homePage,layout,darkTheme,favicon. var staticPages: [any StaticPage]lists all pages; theSiteprotocol provides the builder behavior, sofor/ifblocks work without requiring@StaticPageBuilderon the property declaration.
5. Styling
- Margin/padding:
.margin(.top,.px(20)),.margin(20)(px shorthand),.padding(.all,.large)(Bootstrap semantic). - Frame:
.frame(maxWidth: 230),.frame(width:.percent(50)). Int values auto-convert to.px(). - Color:
.foregroundStyle(.bootstrapPurple),.init(hex: "#FF0000"). - Typography:
.font(.title1),.fontWeight(.bold). - Full-width:
.ignorePageGutters().
6. Interactive Components
Modal(id:)for modal dialogs, triggered byShowModal(id:)/DismissModal(id:).Gridwith.columns(N)for grid layouts.ZStack(alignment:)for overlapping content..onClick {ShowModal(id: "myModal")}for click handlers.ForEach/InlineForEachfor iterating collections.