Skip to content

Commit 47aa7c8

Browse files
committed
add favicon
1 parent f73446d commit 47aa7c8

File tree

15 files changed

+155
-59
lines changed

15 files changed

+155
-59
lines changed

Assets/icons/favicon.ico

41.6 KB
Binary file not shown.

Assets/icons/favicon.png

2.75 KB
Loading

Assets/icons/favicon.svg

Lines changed: 90 additions & 0 deletions
Loading

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div align="center">
22

3-
<strong><em><code>unidoc</code></em></strong><br><small><code>0.1.3</code></small>
3+
<strong><em><code>unidoc</code></em></strong><br><small><code>0.1.4</code></small>
44

55
[![ci build status](https://github.com/kelvin13/swift-unidoc/actions/workflows/build.yml/badge.svg)](https://github.com/kelvin13/swift-unidoc/actions/workflows/build.yml)
66

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
extension HTML.AttributeEncoder
2+
{
3+
@inlinable public
4+
var rel:HTML.Attribute.Rel?
5+
{
6+
get
7+
{
8+
nil
9+
}
10+
set(value)
11+
{
12+
self[name: .rel] = value?.rawValue
13+
}
14+
}
15+
}

Sources/HTMLDOM/Encoding/HTML.AttributeEncoder.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,3 @@ extension HTML.AttributeEncoder
7474
}
7575
}
7676
}
77-
extension HTML.AttributeEncoder
78-
{
79-
@inlinable public
80-
var rel:HTML.Attribute.Rel?
81-
{
82-
get
83-
{
84-
nil
85-
}
86-
set(value)
87-
{
88-
self[name: .rel] = value?.rawValue
89-
}
90-
}
91-
}

Sources/UnidocPages/FixedPage.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import HTML
22
import HTTPServer
3+
import Media
34
import URI
45

56
public
@@ -42,7 +43,17 @@ extension FixedPage
4243
$0.name = "viewport"
4344
$0.content = "width=device-width, initial-scale=1"
4445
}
45-
$0[.link] { $0.href = "\(Site.Asset.main_css)" ; $0.rel = .stylesheet }
46+
$0[.link]
47+
{
48+
$0.href = "\(Site.Asset.favicon_png)"
49+
$0.type = "\(MediaType.image(.png))"
50+
$0.rel = .icon
51+
}
52+
$0[.link]
53+
{
54+
$0.href = "\(Site.Asset.main_css)"
55+
$0.rel = .stylesheet
56+
}
4657
// Inlining this saves the client a round-trip to the google fonts API.
4758
// It is only about 1.87 KB, which is less than 5 percent of the total
4859
// size of a typical page.

Sources/UnidocPages/Templates/Site.Asset.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ extension Site
55
@frozen public
66
enum Asset:String, Equatable, Hashable, Sendable
77
{
8+
case favicon_ico = "favicon.ico"
9+
case favicon_png = "favicon.png"
810
// We let Google Fonts serve most of the fonts, but we host Literata ourselves because
911
// the front-end CSS uses opentype features such as old-style numerals, and Google
1012
// Fonts strips those out.

Sources/UnidocServer/Caching/Cache.Request.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ extension Cache
1717
}
1818
extension Cache.Request
1919
{
20-
func load(from cache:Cache<Key>) async throws -> ServerResponse?
20+
func load(from cache:Cache<Key>) async throws -> ServerResponse
2121
{
22-
guard var resource:ServerResource = try await cache.load(self.key)
23-
else
24-
{
25-
return nil
26-
}
22+
var resource:ServerResource = try await cache.load(self.key)
2723

2824
if let tag:MD5 = self.tag,
2925
case tag? = resource.hash

0 commit comments

Comments
 (0)