2026-06-28 05:07:19 +00:00
|
|
|
import Elementary
|
2026-06-29 23:08:36 +00:00
|
|
|
import Foundation
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
/// 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.
|
|
|
|
|
/// - Parameter locale: the locale the page content is localized to.
|
|
|
|
|
init(
|
|
|
|
|
locale: Locale
|
|
|
|
|
) {
|
|
|
|
|
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-19 08:56:35 +00:00
|
|
|
var scripts: [StaticFile] {
|
|
|
|
|
[.index, .shared]
|
2026-06-28 05:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
2026-07-19 08:56:35 +00:00
|
|
|
var stylesheets: [StaticFile] {
|
|
|
|
|
[.shared, .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
|
|
|
|
|
|
|
|
}
|