Improved the static assets definitions in the Website service (#18)
This PR contains the work done to overhaul the static asset definitions for the Website service.
To provide further details about the work:
* Website library
* Overhauled the `StateFile` enumeration to reduce the number of cases to one case per logical file name, each exposing a `fileExtensions` list.
* Wired everything into the pages with a consistent ordering convention: stylesheets load shared-first so the page sheet wins the CSS cascade; scripts load page-first with shared.js last. The error page also gained the shared stylesheet and its scripts; the index page gained its page CSS/JS and the new touch icon link.
* Used the `StaticFile` enumeration as a single source of truth for every _href_/_src_ in the `IndexPage` and the `ErrorPage` pages, eliminating hardcoded asset paths.
* Website service
* Added new assets to the Resources folder:
* `apple-touch-icon.png`
* `css/index.css`
* `js/index.js`
* `js/error.js`
* `sitemap.xml`
* Renamed existing assets within the Resources folder:
* `css/style.css` → `css/shared.css`
* `js/app.js` → `js/shared.js`
* Fixed the working-directory location for the scheme in the Xcode project.
Reviewed-on: rock-n-code/loud-amsterdam#18
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit is contained in:
@@ -26,12 +26,13 @@ struct IndexPage: HTMLDocument, Sendable {
|
||||
|
||||
// MARK: Document
|
||||
|
||||
/// The page's content: a localized greeting followed by the app script.
|
||||
/// The page's content: a localized greeting followed by the shared and index scripts.
|
||||
var body: some HTML {
|
||||
p {
|
||||
localize("index.greeting", locale: locale)
|
||||
}
|
||||
script(.src("/js/app.js")) {}
|
||||
script(.src(StaticFile.index.urlPath(for: .js))) {}
|
||||
script(.src(StaticFile.shared.urlPath(for: .js))) {}
|
||||
}
|
||||
|
||||
/// The metadata, stylesheet, icon, and manifest links placed in the document head.
|
||||
@@ -43,11 +44,15 @@ struct IndexPage: HTMLDocument, Sendable {
|
||||
)
|
||||
link(
|
||||
.rel(.stylesheet),
|
||||
.href("/css/style.css")
|
||||
.href(StaticFile.shared.urlPath(for: .css))
|
||||
)
|
||||
link(
|
||||
.rel(.stylesheet),
|
||||
.href(StaticFile.index.urlPath(for: .css))
|
||||
)
|
||||
link(
|
||||
.rel(.icon),
|
||||
.href("/favicon.ico"),
|
||||
.href(StaticFile.favicon.urlPath(for: .ico)),
|
||||
.custom(
|
||||
name: "sizes",
|
||||
value: "any"
|
||||
@@ -55,7 +60,7 @@ struct IndexPage: HTMLDocument, Sendable {
|
||||
)
|
||||
link(
|
||||
.rel(.icon),
|
||||
.href("/icon.svg"),
|
||||
.href(StaticFile.icon.urlPath(for: .svg)),
|
||||
.custom(
|
||||
name: "type",
|
||||
value: "image/svg+xml"
|
||||
@@ -63,11 +68,11 @@ struct IndexPage: HTMLDocument, Sendable {
|
||||
)
|
||||
link(
|
||||
.rel("apple-touch-icon"),
|
||||
.href("/icon.png")
|
||||
.href(StaticFile.appleTouchIcon.urlPath(for: .png))
|
||||
)
|
||||
link(
|
||||
.rel("manifest"),
|
||||
.href("/site.webmanifest")
|
||||
.href(StaticFile.site.urlPath(for: .webmanifest))
|
||||
)
|
||||
meta(
|
||||
.name("theme-color"),
|
||||
|
||||
Reference in New Issue
Block a user