Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Swift HTML Website

A modern website built with Swift using the swift-html library and Vapor web framework.

Features

  • 🎨 Type-safe HTML generation
  • ✅ Compile-time validation
  • 🚀 Fast and modern web framework (Vapor)
  • 📦 Easy to extend and transform

Prerequisites

  • Swift 5.9 or later
  • macOS 13.0 or later (for running the server)
  • Xcode Command Line Tools

Installation

  1. Clone or navigate to this directory:
cd swift-html-website
  1. Build the project:
swift build
  1. Run the server:
swift run App

The server will start on http://localhost:8080

Available Routes

  • / - Home page
  • /about - About page
  • /contact - Contact page

Project Structure

swift-html-website/
├── Package.swift          # Swift Package Manager configuration
├── Sources/
│   └── App/
│       └── main.swift     # Main server code with routes
└── README.md             # This file

How It Works

This project uses:

  1. swift-html: A DSL for building type-safe HTML documents in Swift
  2. Vapor: A powerful web framework for Swift
  3. swift-html-vapor: Integration between swift-html and Vapor

The HTML is generated using Swift's type system, which means:

  • Invalid HTML won't compile
  • You get autocomplete and type checking
  • You can transform HTML documents programmatically
  • No runtime template errors

Example HTML Generation

let html = Node.document(
    .html(
        .head(
            .title("My Page")
        ),
        .body(
            .h1("Hello, World!"),
            .p("This is a paragraph.")
        )
    )
)

Learn More

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages