@@ -15,7 +15,7 @@ public struct HomePage: Page {
15
15
return formatter
16
16
} ( )
17
17
18
- let styling = Style ( )
18
+ let styling : HomePage . Style = Style ( )
19
19
20
20
public var content : some HTML {
21
21
HTMLRaw ( " <!DOCTYPE html> " )
@@ -32,9 +32,9 @@ public struct HomePage: Page {
32
32
script { HTMLRaw ( " hljs.highlightAll(); " ) }
33
33
VueScript ( )
34
34
}
35
- body ( . v. scope ( " { showCode: true } " ) ) {
35
+ body ( . v. scope ( " { showCode: true, selection: undefined } " ) ) {
36
36
header ( . class( " wrapped " ) ) {
37
- // TODO: Allow changing from swift-syntax based language to regular
37
+ // TODO: Allow changing from swift-syntax based language to plain text, and other languages?
38
38
div ( . class( " container " ) , . style( " height: 3rem " ) ) { }
39
39
}
40
40
main {
@@ -123,7 +123,7 @@ public struct HomePage: Page {
123
123
. d( " M128,16a88.1,88.1,0,0,0-88,88c0,75.3,80,132.17,83.41,134.55a8,8,0,0,0,9.18,0C136,236.17,216,179.3,216,104A88.1,88.1,0,0,0,128,16Zm0,56a32,32,0,1,1-32,32A32,32,0,0,1,128,72Z " )
124
124
)
125
125
}
126
- " \( residency) "
126
+ " \( residency) "
127
127
}
128
128
129
129
@HTMLBuilder
@@ -143,7 +143,7 @@ public struct HomePage: Page {
143
143
path ( . d( " M237.33,106.21,61.41,41l-.16-.05A16,16,0,0,0,40.9,61.25a1,1,0,0,0,.05.16l65.26,175.92A15.77,15.77,0,0,0,121.28,248h.3a15.77,15.77,0,0,0,15-11.29l.06-.2,21.84-78,78-21.84.2-.06a16,16,0,0,0,.62-30.38ZM149.84,144.3a8,8,0,0,0-5.54,5.54L121.3,232l-.06-.17L56,56l175.82,65.22.16.06Z " ) )
144
144
}
145
145
146
- " Currently in "
146
+ " Currently in "
147
147
148
148
b {
149
149
[ location. city, location. state, location. region == " United States " ? nil : location. region]
@@ -161,7 +161,7 @@ public struct HomePage: Page {
161
161
162
162
private struct PostsSection : HTML {
163
163
var content : some HTML {
164
- section ( . id( " posts " ) , . class( " wrapped " ) , . v . scope ( " { selection: undefined } " ) ) {
164
+ section ( . id( " posts " ) , . class( " wrapped " ) ) {
165
165
div ( . class( " container " ) ) {
166
166
code ( . class( " code-tag " ) ) { " Posts.swift " }
167
167
@@ -196,24 +196,82 @@ public struct HomePage: Page {
196
196
// }
197
197
}
198
198
199
- for (idx, post) in Post . allCases. enumerated ( ) {
199
+ for (idx, post) in Post . allCases. reversed ( ) . enumerated ( ) {
200
200
article (
201
201
. class( " post " ) ,
202
202
. v. show ( " !selection || selection == ' \( post. kind. rawValue) ' " )
203
203
) {
204
204
header {
205
- div ( . style( " display: flex " ) ) {
205
+ section ( . style( " display: flex; align-items: baseline; " ) ) {
206
206
span ( . class( " post__date " ) , . style( " flex-grow: 1 " ) ) { post. dateFormatted }
207
207
208
- pre {
208
+ pre {
209
209
code ( . class( " hljs language-swift " ) , . style( " font-size: 0.75em; color: #777; font-weight: 500 " ) ) {
210
210
" post[ \( idx) ] "
211
- }
211
+ }
212
+ }
213
+ }
214
+
215
+ if let postHeader = post. header {
216
+ section {
217
+ switch postHeader {
218
+ case let . link( link) :
219
+ EmptyHTML ( )
220
+ case let . image( src, label) :
221
+ img ( . src( src) , . class( " post__header " ) , . custom( name: " alt " , value: label) , . aria. label ( label) )
222
+ case let . video( src) :
223
+ video (
224
+ . class( " post__header " ) ,
225
+ . custom( name: " autoplay " , value: " " ) ,
226
+ . custom( name: " playsinline " , value: " " ) ,
227
+ . custom( name: " muted " , value: " " ) ,
228
+ . custom( name: " controls " , value: " " ) ,
229
+ . custom( name: " loop " , value: " " )
230
+ ) {
231
+ source ( . src( src) )
232
+ " Your browser does not support playing this video "
233
+ }
234
+ case let . code( rawCode, lang) :
235
+ pre ( . class( " post__header " ) ) {
236
+ code ( . class( " hljs language- \( lang. rawValue) " ) ) {
237
+ HTMLRaw ( rawCode)
238
+ }
239
+ }
240
+ }
212
241
}
213
242
}
214
243
}
215
- h3 ( . class( " post__time " ) ) { post. title }
244
+ h3 ( . class( " post__title " ) ) { post. title }
216
245
section ( . class( " post__content " ) ) { post. content }
246
+
247
+ if !post. links. isEmpty {
248
+ section ( . class( " post__links " ) ) {
249
+ for link in post. links {
250
+ a (
251
+ . href( link. href) ,
252
+ . target( . blank) ,
253
+ . rel( " noopener noreferrer " ) ,
254
+ . class( " post__link- \( link. role. rawValue) " )
255
+ ) {
256
+ HTMLText ( link. title)
257
+ " "
258
+ if link. isExternal {
259
+ svg ( . xmlns( ) , . fill( " currentColor " ) , . viewBox( " 0 0 256 256 " ) , . class( " svg-icon " ) , . aria. label ( " external link icon " ) ) {
260
+ path (
261
+ . d( " M228,104a12,12,0,0,1-24,0V69l-59.51,59.51a12,12,0,0,1-17-17L187,52H152a12,12,0,0,1,0-24h64a12,12,0,0,1,12,12Zm-44,24a12,12,0,0,0-12,12v64H52V84h64a12,12,0,0,0,0-24H48A20,20,0,0,0,28,80V208a20,20,0,0,0,20,20H176a20,20,0,0,0,20-20V140A12,12,0,0,0,184,128Z " )
262
+ )
263
+ }
264
+ } else {
265
+ svg ( . xmlns( ) , . fill( " currentColor " ) , . viewBox( " 0 0 256 256 " ) , . class( " svg-icon " ) , . aria. label ( " external link icon " ) ) {
266
+ path (
267
+ . d( " M224.49,136.49l-72,72a12,12,0,0,1-17-17L187,140H40a12,12,0,0,1,0-24H187L135.51,64.48a12,12,0,0,1,17-17l72,72A12,12,0,0,1,224.49,136.49Z " )
268
+ )
269
+ }
270
+ }
271
+ }
272
+ }
273
+ }
274
+ }
217
275
}
218
276
}
219
277
}
@@ -300,7 +358,7 @@ extension HomePage {
300
358
}
301
359
302
360
Class ( " container " ) => {
303
- AnyProperty ( " max-width " , " 46rem " )
361
+ AnyProperty ( " max-width " , " 40rem " )
304
362
AnyProperty ( " margin-right " , " auto " )
305
363
AnyProperty ( " margin-left " , " auto " )
306
364
AnyProperty ( " border-left " , " 1px solid #303030 " )
@@ -334,7 +392,6 @@ extension HomePage {
334
392
AnyProperty ( " bottom " , " 0.125em " )
335
393
AnyProperty ( " width " , " 1em " )
336
394
AnyProperty ( " height " , " 1em " )
337
- AnyProperty ( " margin-right " , " 0.25rem " )
338
395
}
339
396
340
397
Class ( " reversed " ) => {
@@ -415,15 +472,71 @@ extension HomePage {
415
472
AnyProperty ( " font-weight " , " 600 " )
416
473
}
417
474
418
- Class ( " post__time " ) => {
475
+ Class ( " post__title " ) => {
419
476
AnyProperty ( " margin-top " , " 0.5rem " )
420
477
}
421
478
422
479
Class ( " post__content " ) * All( ) => {
423
480
AnyProperty ( " margin " , " revert " )
424
481
}
425
482
426
- Class ( " post__content " ) * Element( . pre) => {
483
+ Class ( " post__content " ) * Element( . blockquote) => {
484
+ // AnyProperty("all", "unset")
485
+ AnyProperty ( " display " , " block " )
486
+ AnyProperty ( " background " , " #2A2A2A " )
487
+ AnyProperty ( " border " , " 1.5px solid #4A4A4A " )
488
+ AnyProperty ( " padding " , " 0.125rem 1rem " )
489
+ AnyProperty ( " margin-right " , " 0 " )
490
+ AnyProperty ( " margin-left " , " 0 " )
491
+ AnyProperty ( " border-radius " , " 0.5rem " )
492
+ }
493
+
494
+ Class ( " post__header " ) => {
495
+ AnyProperty ( " width " , " 100% " )
496
+ AnyProperty ( " margin-top " , " 1.25rem " )
497
+ AnyProperty ( " margin-bottom " , " 1.25rem " )
498
+ AnyProperty ( " border-color " , " #3A3A3A " )
499
+ AnyProperty ( " border-style " , " solid " )
500
+ AnyProperty ( " border-width " , " 1.5px " )
501
+ AnyProperty ( " border-radius " , " 0.5rem " )
502
+ }
503
+
504
+ Class ( " post__links " ) => {
505
+ AnyProperty ( " display " , " flex " )
506
+ AnyProperty ( " gap " , " 0.75rem " )
507
+ AnyProperty ( " margin-top " , " 1.5rem " )
508
+ }
509
+
510
+ " .post__link-primary, .post__link-secondary, .post__link-tertiary " => {
511
+ AnyProperty ( " all " , " unset " )
512
+ AnyProperty ( " font-size " , " 0.85em " )
513
+ AnyProperty ( " font-weight " , " 550 " )
514
+ AnyProperty ( " align-content " , " center " )
515
+ AnyProperty ( " min-height " , " 1.5rem " )
516
+ AnyProperty ( " min-width " , " 2rem " )
517
+ AnyProperty ( " padding " , " 0.375rem 0.75rem " )
518
+ AnyProperty ( " cursor " , " pointer " )
519
+ AnyProperty ( " border-radius " , " 0.5rem " )
520
+ }
521
+
522
+ Class ( " post__link-primary " ) => {
523
+ Color ( . white)
524
+ AnyProperty ( " background " , " linear-gradient(to bottom, hsla(0, 0%, 24%, 1), hsla(0, 0%, 16%, 1)) " )
525
+ AnyProperty ( " box-shadow " , " inset 0 1px 1px rgba(255, 255, 255, 0.12) " )
526
+ }
527
+
528
+ Class ( " post__link-secondary " ) => {
529
+ Color ( . black)
530
+ AnyProperty ( " box-shadow " , " inset 0px -1px 2px 0px hsl(0 0% 50% / 0.5) " )
531
+ AnyProperty ( " background " , " linear-gradient(to bottom, hsl(0deg 0% 100%), hsl(0deg 0% 92.91%)) " )
532
+ }
533
+
534
+ Class ( " post__link-tertiary " ) => {
535
+ Color ( . white)
536
+ AnyProperty ( " background " , " hsla(0, 0%, 50%, 0.25) " )
537
+ }
538
+
539
+ " .post__content pre, .post__header pre " => {
427
540
AnyProperty ( " padding " , " 0.75rem " )
428
541
Background ( " #242424 " )
429
542
AnyProperty ( " border-color " , " #3A3A3A " )
0 commit comments