2026-06-28 05:07:19 +00:00
|
|
|
import Elementary
|
2026-06-29 23:08:36 +00:00
|
|
|
import Foundation
|
2026-07-23 01:04:37 +00:00
|
|
|
import Infrastructure
|
2026-06-29 23:08:36 +00:00
|
|
|
import Localization
|
2026-06-28 05:07:19 +00:00
|
|
|
|
2026-06-29 23:08:36 +00:00
|
|
|
/// The website's landing page, with its text localized to a given locale.
|
2026-07-19 08:56:35 +00:00
|
|
|
struct IndexPage {
|
2026-06-28 05:07:19 +00:00
|
|
|
|
2026-06-29 23:08:36 +00:00
|
|
|
// MARK: Properties
|
|
|
|
|
|
2026-08-13 02:57:47 +02:00
|
|
|
/// The analytics tracker embedded as a deferred script in the document head, or `nil` to omit it.
|
|
|
|
|
let analytics: Analytics?
|
|
|
|
|
|
2026-07-23 01:04:37 +00:00
|
|
|
/// The version token appended to the page's asset URLs, or `nil` to leave them unversioned.
|
|
|
|
|
let assetVersion: String?
|
|
|
|
|
|
2026-06-29 23:08:36 +00:00
|
|
|
/// The locale the page content is localized to.
|
2026-07-19 08:56:35 +00:00
|
|
|
let locale: Locale
|
2026-06-29 23:08:36 +00:00
|
|
|
|
|
|
|
|
/// Resolves the page's text from the bundled String Catalog for the page's ``locale``.
|
|
|
|
|
private let localize: Localize
|
|
|
|
|
|
|
|
|
|
// MARK: Initializers
|
|
|
|
|
|
|
|
|
|
/// Creates a landing page localized to the given locale.
|
2026-07-23 01:04:37 +00:00
|
|
|
/// - Parameters:
|
|
|
|
|
/// - locale: the locale the page content is localized to.
|
2026-07-30 06:33:57 +00:00
|
|
|
/// - assetVersion: the version token appended to the page's asset URLs, or `nil` (the default) to leave them unversioned.
|
2026-08-13 02:57:47 +02:00
|
|
|
/// - analytics: the analytics tracker embedded in the document head, or `nil` (the default) to omit it.
|
2026-06-29 23:08:36 +00:00
|
|
|
init(
|
2026-07-23 01:04:37 +00:00
|
|
|
locale: Locale,
|
2026-08-13 02:57:47 +02:00
|
|
|
assetVersion: String? = nil,
|
|
|
|
|
analytics: Analytics? = nil
|
2026-06-29 23:08:36 +00:00
|
|
|
) {
|
2026-08-13 02:57:47 +02:00
|
|
|
self.analytics = analytics
|
2026-07-23 01:04:37 +00:00
|
|
|
self.assetVersion = assetVersion
|
2026-06-29 23:08:36 +00:00
|
|
|
self.locale = locale
|
|
|
|
|
self.localize = .init(bundle: .module)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-19 08:56:35 +00:00
|
|
|
}
|
2026-06-28 05:07:19 +00:00
|
|
|
|
2026-07-19 08:56:35 +00:00
|
|
|
// MARK: - Page
|
|
|
|
|
|
|
|
|
|
extension IndexPage: Page {
|
|
|
|
|
|
|
|
|
|
// MARK: Properties
|
|
|
|
|
|
|
|
|
|
var content: some HTML {
|
2026-06-29 23:08:36 +00:00
|
|
|
p {
|
|
|
|
|
localize("index.greeting", locale: locale)
|
|
|
|
|
}
|
2026-06-28 05:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
2026-07-23 01:04:37 +00:00
|
|
|
var scripts: [any Asset] {
|
|
|
|
|
[StaticFile.index, StaticFile.shared]
|
2026-06-28 05:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
2026-07-23 01:04:37 +00:00
|
|
|
var stylesheets: [any Asset] {
|
|
|
|
|
[StaticFile.shared, StaticFile.index]
|
2026-06-28 05:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
2026-06-28 14:18:04 +00:00
|
|
|
var title: String {
|
2026-06-29 23:08:36 +00:00
|
|
|
localize("index.title", locale: locale)
|
2026-06-28 14:18:04 +00:00
|
|
|
}
|
2026-06-28 05:07:19 +00:00
|
|
|
|
|
|
|
|
}
|