Skip to content

Commit 48350f7

Browse files
committed
feat(pages): change assets to using webp and webm
add last updated to post and add minor code syntax
1 parent bb952d5 commit 48350f7

37 files changed

+46
-19
lines changed

Sources/Pages/Components/SectionView.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Vue
55

66
struct SectionView<Content: HTML>: HTML {
77
let id: String
8-
let selectedCodeLang: Vue.Expression<CodeLang>
8+
let selected: Vue.Expression<CodeLang>
99
let codeHeader: @Sendable (CodeLang) -> String
1010
@HTMLBuilder let content: @Sendable () -> Content
1111

@@ -15,7 +15,7 @@ struct SectionView<Content: HTML>: HTML {
1515
header {
1616
pre {
1717
a(.href("#\(self.id)")) {
18-
CodeLang.conditionalCases(initial: selectedCodeLang) { lang in
18+
CodeLang.conditionalCases(initial: selected) { lang in
1919
code {
2020
slugToFileName(lang)
2121
}
@@ -27,9 +27,8 @@ struct SectionView<Content: HTML>: HTML {
2727
.inlineStyle("font-weight", "500")
2828
.inlineStyle("text-align", "end")
2929
.inlineStyle("padding", "1.5rem 1.5rem 0")
30-
3130
pre {
32-
CodeLang.conditionalCases(initial: selectedCodeLang) { lang in
31+
CodeLang.conditionalCases(initial: selected) { lang in
3332
code(.class("hljs language-\(lang.rawValue)")) {
3433
"""
3534
// \(slugToFileName(lang))
@@ -41,7 +40,6 @@ struct SectionView<Content: HTML>: HTML {
4140
}
4241
.inlineStyle("padding", "0.75rem 1.5rem 1.5rem")
4342
}
44-
4543
self.content()
4644
}
4745
.containerStyling()

Sources/Pages/HomePage.swift

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private struct UserView: HTML {
5858

5959
@HTMLBuilder
6060
var body: some HTML {
61-
SectionView(id: "user", selectedCodeLang: selected) { lang in
61+
SectionView(id: "user", selected: selected) { lang in
6262
switch lang {
6363
case .swift:
6464
"""
@@ -85,7 +85,7 @@ private struct UserView: HTML {
8585
role: "Mobile & Web Developer",
8686
home: "\(residency ?? .default)"\
8787
\(currentLocation.flatMap { ",\n location: \"Currently in \($0)\"" } ?? "")
88-
}
88+
};
8989
"""
9090
}
9191
} content: {
@@ -111,19 +111,19 @@ private struct UserView: HTML {
111111
private struct PostsView: HTML {
112112
let selected: Vue.Expression<CodeLang>
113113
var body: some HTML {
114-
SectionView(id: "dev-logs", selectedCodeLang: selected) { lang in
114+
SectionView(id: "dev-logs", selected: selected) { lang in
115115
switch lang {
116116
case .swift:
117117
"""
118118
let logs: [DevLog] = await fetch(.all)
119119
"""
120120
case .typescript:
121121
"""
122-
const logs = await fetch(Filter.All)
122+
const logs = await fetch(Filter.All);
123123
"""
124124
case .rust:
125125
"""
126-
let logs = fetch(Filter::All).await
126+
let logs = fetch(Filter::All).await;
127127
"""
128128
}
129129
} content: {
@@ -195,6 +195,19 @@ private struct PostsView: HTML {
195195
.inlineStyle("gap", "0.75rem")
196196
.inlineStyle("margin-top", "1.5rem")
197197
}
198+
199+
if let dateUpdated = self.post.dateUpdated {
200+
footer {
201+
em {
202+
"Last updated: "
203+
span { dateUpdated }
204+
}
205+
}
206+
.inlineStyle("color", "#8A8A8A")
207+
.inlineStyle("font-size", "0.84em")
208+
.inlineStyle("margin-top", "0.5rem")
209+
.inlineStyle("text-align", "end")
210+
}
198211
}
199212
.inlineStyle("width", "100%")
200213
.inlineStyle("display", "inline-block")

Sources/Pages/Models/Post+AllCases.swift

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import PublicAssets
44

55
extension Post: CaseIterable {
66
static var allCases: [Self] {
7-
@Dependency(\.publicAssets) var assets
7+
@Dependency(\.publicAssets) var assetsDir
88

99
return [
1010
Self(
11-
header: .video(assets.assets.posts.wledAppDemoMp4),
11+
header: .video(assetsDir.assets.posts.wledAppDemo.videoWebm),
1212
title: "A WLED Client for iOS",
1313
content: """
1414
I built a native iOS app for [WLED](https://github.com/wled/WLED), an open-source LED controller for ESP32, to control my RGB LED strips.
@@ -25,7 +25,7 @@ extension Post: CaseIterable {
2525
kind: .project
2626
),
2727
Self(
28-
header: .image(assets.assets.projects.animeNow.anDiscoverPng, label: "Anime Now! discover image"),
28+
header: .image(assetsDir.assets.posts.animeNowReleased.anDiscoverWebp, label: "Anime Now! discover image"),
2929
title: "Anime Now! \u{2014} An iOS and macOS App",
3030
content: """
3131
> TBD
@@ -56,15 +56,27 @@ extension Post: CaseIterable {
5656
content: """
5757
I finally decided to redesign my website. \
5858
To expand my skills with Swift, I decided to rebuild my portfolio in Swift.
59+
60+
Additionally, I built a library called [swift-web](https://github.com/erikbdev/swift-web) which contains tools used to build \
61+
this website in Swift. It utilizes Swift build tools to generate typed asset generation, and \
62+
utilities to build a reactive website using Swift and Vue.
63+
64+
Feel free to check out both projects on GitHub. 😊
5965
""",
6066
date: Date(month: 2, day: 2, year: 2025),
67+
lastUpdated: Date(month: 3, day: 14, year: 2025),
6168
kind: .blog,
6269
links: [
6370
Post.Link(
64-
title: "GitHub",
71+
title: "Portfolio",
6572
href: "https://github.com/erikbdev/erikbautista.dev",
6673
role: .primary
6774
),
75+
Post.Link(
76+
title: "swift-web",
77+
href: "https://github.com/erikbdev/swift-web",
78+
role: .secondary
79+
),
6880
]
6981
),
7082
]

Sources/Pages/Models/Post.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ struct Post: Sendable {
2323
Self.dateCreatedFormatter.string(from: self.date)
2424
}
2525

26+
var dateUpdated: String? {
27+
self.lastUpdated.flatMap(Self.dateCreatedFormatter.string(from:))
28+
}
29+
2630
private static let timestampFormatter = {
2731
let formatter = DateFormatter()
2832
formatter.locale = Locale(identifier: "en_US_POSIX")

Sources/Pages/NotFoundPage.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public struct NotFoundPage: Page {
1717
}
1818

1919
public var body: some HTML {
20-
#VueScope(initialCodeLang) { selected in
21-
HeaderView(selected: selected)
20+
#VueScope(initialCodeLang) { codeLang in
21+
HeaderView(selected: codeLang)
2222
Spacer()
2323
main {
2424
section {
@@ -34,7 +34,7 @@ public struct NotFoundPage: Page {
3434
.inlineStyle("margin-bottom", "0.5rem")
3535

3636
pre {
37-
CodeLang.conditionalCases(initial: selected) { lang in
37+
CodeLang.conditionalCases(initial: codeLang) { lang in
3838
code {
3939
switch lang {
4040
case .swift:
@@ -43,11 +43,11 @@ public struct NotFoundPage: Page {
4343
"""
4444
case .rust:
4545
"""
46-
panic!("page not found")
46+
panic!("page not found");
4747
"""
4848
case .typescript:
4949
"""
50-
throw new Error("page not found")
50+
throw new Error("page not found");
5151
"""
5252
}
5353
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)