使用 Swift 和 Tailwind CSS 构建静态网页。
Slipstream 是一个专为 Swift 开发者构建的静态站点生成器。
克隆 Slipstream 站点模板,以便快速开始将 Slipstream 站点部署到 GitHub Pages。
mkdir mysite
cd mysite
swift package init --type executable
Slipstream 需要 macOS 14。
platforms: [
.macOS("14"),
],
dependencies: [
.package(url: "https://github.com/jverkoey/slipstream.git", branch: "main"),
],
targets: [
.executableTarget(name: "mysite", dependencies: [
.product(name: "Slipstream", package: "slipstream"),
]
],
即可开始
import Foundation
import Slipstream
struct HelloWorld: View {
var body: some View {
Text("Hello, world!")
}
}
print(try renderHTML(HelloWorld()))
Slipstream 有意避免对你的文档应如何组织结构和写入磁盘做出强烈的预设。不过,为了帮助你入门,你可以使用 Slipstream 的轻量级站点地图渲染器,将 Slipstream 视图字典写入磁盘
import Foundation
import Slipstream
struct HelloWorld: View {
var body: some View {
Text("Hello, world!")
}
}
let sitemap: Sitemap = [
"index.html": HelloWorld()
]
// Assumes this file is located in a Sources/ sub-directory of a Swift package.
guard let projectURL = URL(filePath: #filePath)?
.deletingLastPathComponent()
.deletingLastPathComponent() else {
print("Unable to create URL for \(#filePath)")
exit(1)
}
let outputURL = projectURL.appending(path: "site")
try renderSitemap(sitemap, to: outputURL)
查看 Slipstream 的完整文档。
要与其他 Slipstream 用户讨论 Slipstream 相关主题、提问或探索想法,请使用 GitHub 讨论区。