Skip to content

maclong9/web-ui

A library for generating websites in a simple, type-safe, and consistent manner.

Report a Bug· Request a Feature· Ask a Question Documentation

license PRs welcome Run Tests

Table of Contents

About

WebUI is a library for generating Web User Interfaces in a simple, type-safe, and consistent manner. It is inspired by modern web development practices and aims to provide a seamless experience for developers building static sites or dynamic web applications.

Built With

Getting Started

Prerequisites

To use WebUI, ensure you have the following installed:

  • Swift 6.1 or later

Usage

Script

curl -fsSL https://github.com/raw/maclong9/web-ui/main/initialize.swift |
  swift - [--template|-t static|server] your-project-name

Note

If you pass no template the static one will be used by default.

Manually

Add the following to your package dependencies:

dependencies: [
    .package(url: "https://github.com/maclong9/web-ui.git", from: "1.0.0")
  ],

And then add this to your Target:

 .executableTarget(
      name: "Application",
      dependencies: [
        .product(name: "WebUI", package: "web-ui")
      ],
      path: "Sources",
      resources: [.process("Public")]
    )

Static Site Building

The recommended approach is the GitHub action within the .github/workflows directory, this will build the site and push the changes to a static branch, you can then use this branch with most deployment providers such as Cloudflare Pages and Netlify. Below are two examples, one that uses the default options and one with some customisations for working within a monorepo, both of these examples are used in production here: portfolio and comp-sci.

With Defaults

name: Build Static Site

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build:
    uses: maclong9/web-ui/.github/workflows/build.yml@main

With Custom Options

name: Build Static Site
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build:
    uses: maclong9/web-ui/.github/workflows/build.yml@main
    with:
      working-directory: 'Application'
      generate-command: 'swift run Application'

Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are greatly appreciated.

Please see our CONTRIBUTING.md document for detailed guidelines on how to contribute to this project. All contributors are expected to adhere to our Code of Conduct.

Funding

WebUI is an independent open-source project that relies on community support. If you find it useful, please consider supporting its development:

Your support helps ensure WebUI remains actively maintained and continuously improved. Organizations using WebUI in production are especially encouraged to contribute financially to ensure the project's long-term sustainability.

Support

Reach out to the maintainer at one of the following places:

License

This project is licensed under the Apache 2.0 license. See LICENSE for more information.

Acknowledgements

Thanks to the following resources that inspired WebUI:

About

Render web pages and static sites in Swift.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

Languages