Added font preload links to the Page+Defaults extension in the Website library target.
This commit is contained in:
@@ -32,6 +32,13 @@ struct IndexPageTests {
|
||||
#expect(html.contains("/js/index.js"))
|
||||
}
|
||||
|
||||
@Test
|
||||
func `renders no font preloads until fonts are declared`() {
|
||||
// The template ships no fonts, so a preload link here would point at a file the service does not serve.
|
||||
#expect(IndexPage.preloadedFonts.isEmpty)
|
||||
#expect(!IndexPage(locale: .init(identifier: "en")).render().contains(#"rel="preload""#))
|
||||
}
|
||||
|
||||
@Test
|
||||
func `renders versioned asset URLs when given a version`() {
|
||||
let html = IndexPage(
|
||||
|
||||
@@ -24,6 +24,15 @@ struct StaticFileTests {
|
||||
#expect(file.fileExtensions.map(file.relativePath) == paths)
|
||||
}
|
||||
|
||||
/// A preload URL must match the stylesheet's `@font-face` source exactly, so it carries the extension's folder and no version query.
|
||||
@Test
|
||||
func `unversioned font paths`() {
|
||||
let font = File("a-font-400", as: .woff2)
|
||||
|
||||
#expect(font.relativePath(for: .woff2) == "font/a-font-400.woff2")
|
||||
#expect(font.urlPath(for: .woff2) == "/font/a-font-400.woff2")
|
||||
}
|
||||
|
||||
// MARK: Constants tests
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user