2026-07-23 01:04:37 +00:00
|
|
|
import Infrastructure
|
|
|
|
|
|
2026-06-27 10:59:32 +00:00
|
|
|
/// A static file shipped with the website service.
|
|
|
|
|
///
|
2026-07-19 02:08:59 +00:00
|
|
|
/// Each case identifies a file name stored under the static files root (the `Resources/Static`
|
|
|
|
|
/// directory) and served by Hummingbird's `FileMiddleware` middleware. A name can be available
|
|
|
|
|
/// with more than one extension (see ``fileExtensions``), each resolving to its own file.
|
2026-07-23 01:04:37 +00:00
|
|
|
enum StaticFile: Asset, CaseIterable {
|
2026-07-19 02:08:59 +00:00
|
|
|
/// The `apple-touch-icon.png` icon.
|
|
|
|
|
case appleTouchIcon
|
|
|
|
|
/// The `css/error.css` stylesheet and `js/error.js` script for the not-found page.
|
|
|
|
|
case error
|
2026-06-27 10:59:32 +00:00
|
|
|
/// The `favicon.ico` icon.
|
2026-07-19 02:08:59 +00:00
|
|
|
case favicon
|
2026-07-19 03:35:50 +00:00
|
|
|
/// The `icon.svg` icon.
|
2026-07-19 02:08:59 +00:00
|
|
|
case icon
|
2026-07-19 03:35:50 +00:00
|
|
|
/// The `icon-192.png` icon for the web manifest.
|
|
|
|
|
case icon192
|
|
|
|
|
/// The `icon-512.png` icon for the web manifest.
|
|
|
|
|
case icon512
|
2026-07-19 02:08:59 +00:00
|
|
|
/// The `css/index.css` stylesheet and `js/index.js` script for the landing page.
|
|
|
|
|
case index
|
2026-06-27 10:59:32 +00:00
|
|
|
/// The `robots.txt` crawler directives.
|
2026-07-19 02:08:59 +00:00
|
|
|
case robots
|
|
|
|
|
/// The `css/shared.css` stylesheet and `js/shared.js` script shared across pages.
|
|
|
|
|
case shared
|
2026-06-27 10:59:32 +00:00
|
|
|
/// The `site.webmanifest` web application manifest.
|
2026-07-19 02:08:59 +00:00
|
|
|
case site
|
|
|
|
|
/// The `sitemap.xml` crawler sitemap.
|
|
|
|
|
case sitemap
|
2026-06-27 10:59:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: - Extensions
|
|
|
|
|
|
|
|
|
|
extension StaticFile {
|
|
|
|
|
|
|
|
|
|
// MARK: Computed
|
|
|
|
|
|
2026-07-19 02:08:59 +00:00
|
|
|
/// The file extensions the file is available with.
|
2026-07-23 01:04:37 +00:00
|
|
|
var fileExtensions: [AssetExtension] {
|
2026-07-19 02:08:59 +00:00
|
|
|
switch self {
|
2026-07-19 03:35:50 +00:00
|
|
|
case .appleTouchIcon,
|
|
|
|
|
.icon192,
|
|
|
|
|
.icon512: [.png]
|
2026-07-19 02:08:59 +00:00
|
|
|
case .error,
|
|
|
|
|
.index,
|
|
|
|
|
.shared: [.css, .js]
|
|
|
|
|
case .favicon: [.ico]
|
2026-07-19 03:35:50 +00:00
|
|
|
case .icon: [.svg]
|
2026-07-19 02:08:59 +00:00
|
|
|
case .robots: [.txt]
|
|
|
|
|
case .site: [.webmanifest]
|
|
|
|
|
case .sitemap: [.xml]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The file's name, without extension.
|
|
|
|
|
var fileName: String {
|
|
|
|
|
switch self {
|
|
|
|
|
case .appleTouchIcon: "apple-touch-icon"
|
|
|
|
|
case .error: "error"
|
|
|
|
|
case .favicon: "favicon"
|
|
|
|
|
case .icon: "icon"
|
2026-07-19 03:35:50 +00:00
|
|
|
case .icon192: "icon-192"
|
|
|
|
|
case .icon512: "icon-512"
|
2026-07-19 02:08:59 +00:00
|
|
|
case .index: "index"
|
|
|
|
|
case .robots: "robots"
|
|
|
|
|
case .shared: "shared"
|
|
|
|
|
case .site: "site"
|
|
|
|
|
case .sitemap: "sitemap"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-27 10:59:32 +00:00
|
|
|
}
|