{"id":39439648,"url":"https://github.com/mac9sb/web-ui","last_synced_at":"2026-02-01T16:01:52.933Z","repository":{"id":331525703,"uuid":"1131023966","full_name":"mac9sb/web-ui","owner":"mac9sb","description":"Build web templates in type safe Swift","archived":false,"fork":false,"pushed_at":"2026-01-30T23:41:11.000Z","size":3105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-31T06:54:52.082Z","etag":null,"topics":["ssg","ssr","web"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mac9sb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-09T11:05:37.000Z","updated_at":"2026-01-30T23:41:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mac9sb/web-ui","commit_stats":null,"previous_names":["mac9sb/web-ui"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/mac9sb/web-ui","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mac9sb%2Fweb-ui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mac9sb%2Fweb-ui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mac9sb%2Fweb-ui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mac9sb%2Fweb-ui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mac9sb","download_url":"https://codeload.github.com/mac9sb/web-ui/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mac9sb%2Fweb-ui/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28981893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T15:35:50.179Z","status":"ssl_error","status_checked_at":"2026-02-01T15:35:38.075Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ssg","ssr","web"],"created_at":"2026-01-18T04:18:29.780Z","updated_at":"2026-02-01T16:01:52.921Z","avatar_url":"https://github.com/mac9sb.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebUI\n\nA Swift library for building type-safe, modern websites with support for both static site generation (SSG) and server-side rendering (SSR).\n\n## Overview\n\nWebUI provides a declarative, type-safe API for building websites in Swift:\n\n- **Type-Safe HTML Generation**: Build HTML using Swift's type system\n- **Static Site Generation**: Generate complete websites at build time\n- **Server-Side Rendering**: Render pages dynamically on the server\n- **Component-Based**: Reusable components for common UI patterns\n- **Markdown \u0026 Typst Support**: Write content in Markdown or Typst\n\n## Getting Started\n\n### Installation\n\nAdd WebUI to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/mac9sb/web-ui\", from: \"1.0.0\")\n]\n```\n\nThen add it to your target:\n\n```swift\n.target(\n    name: \"YourTarget\",\n    dependencies: [\n        .product(name: \"WebUI\", package: \"web-ui\"),\n        .product(name: \"WebUITypst\", package: \"web-ui\"), // Optional\n        .product(name: \"WebUIMarkdown\", package: \"web-ui\") // Optional\n    ]\n)\n```\n\n### Static Site Generation\n\nCreate a website:\n\n```swift\nimport WebUI\n\nstruct MyWebsite: Website {\n    var metadata: Metadata {\n        Metadata(\n            title: \"My Website\",\n            description: \"Built with WebUI\"\n        )\n    }\n\n    var routes: [any Document] {\n        [\n            HomePage(),\n            AboutPage()\n        ]\n    }\n}\n```\n\nDefine pages:\n\n```swift\nstruct HomePage: Document {\n    var metadata: Metadata {\n        Metadata(title: \"Home\")\n    }\n\n    var body: some Markup {\n        HTML {\n            Head {\n                Title(\"My Website\")\n                Meta(charset: .utf8)\n            }\n            Body {\n                Header { /* Navigation */ }\n                Main { /* Page content */ }\n                Footer { /* Footer content */ }\n            }\n        }\n    }\n}\n```\n\nBuild the site:\n\n```swift\ntry MyWebsite().build(to: URL(filePath: \".output\"))\n```\n\n### Server-Side Rendering\n\nUse with Hummingbird:\n\n```swift\nimport Hummingbird\nimport WebUI\n\nfunc blogRoutes(_ router: Router) {\n    router.get(\"/blog/:slug\") { request, context -\u003e HTMLResponse in\n        let slug = request.parameters.get(\"slug\", as: String.self)!\n        let page = BlogPostPage(slug: slug)\n        return HTMLResponse(page)\n    }\n}\n```\n\n## Architecture\n\nWebUI consists of several modules:\n\n- **WebUI**: Core library for HTML generation and website building\n- **WebUITypst**: Typst content rendering support\n- **WebUIMarkdown**: Markdown content rendering support\n\n### Key Components\n\n- **Website Protocol**: Define complete websites\n- **Document Protocol**: Define individual pages\n- **Element Protocol**: Build HTML elements type-safely\n- **Markup**: Compose page content\n- **SSRBuilder**: Generate CSS for server-side rendering\n\n## Features\n\n### Type-Safe HTML\n\nBuild HTML using Swift's type system:\n\n```swift\nDiv {\n    Heading(.h1, \"Welcome\")\n    Text(\"Hello, world!\")\n        .font(size: .lg)\n        .textAlign(.center)\n}\n```\n\n### Responsive Design\n\nBuilt-in responsive utilities:\n\n```swift\nVStack {\n    Text(\"Content\")\n        .on {\n            $0.md { $0.font(size: .xl) }\n            $0.sm { $0.font(size: .lg) }\n        }\n}\n```\n\n### CSS Generation\n\nAutomatic CSS generation for SSR mode:\n\n```swift\ntry SSRBuilder(\n    config: CSSOutputConfig(\n        ssrOutputDir: \"Public/\",\n        mode: .ssr\n    )\n).generateCSS(for: allPages)\n```\n\n## Development\n\nTo contribute to WebUI:\n\n1. Clone the repository\n2. Build the project: `swift build`\n3. Run tests: `swift test`\n4. Build documentation: `swift package generate-documentation`\n\n## License\n\nSee LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmac9sb%2Fweb-ui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmac9sb%2Fweb-ui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmac9sb%2Fweb-ui/lists"}