summaryrefslogtreecommitdiff
path: root/website.templ
blob: e95c074aa31ab64484826e67059b78ee159e90ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
package main

templ HeadComponent(title string, description string) {
	<head>
		<meta charset="UTF-8"/>
		<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
		<meta name="color-scheme" content="dark"/>
		<link rel="icon" type="image/svg+xml" href="/public/favicon.svg"/>
		<meta name="darkreader-lock"/>
		<meta name="robots" content="index, follow, noarchive"/>
		<meta name="keywords" content="Kyren223, Krypton, Compiler, Minecraft, Developer, Language, Langdev, Gamedev, Game, Software, Software Engineer, Game developer"/>
		<meta name="author" content="Kyren223"/>
		<meta name="description" content={ description }/>
		<title>{ title }</title>
		<meta property="og:title" content={ title }/>
		<meta property="og:description" content={ description }/>
		<meta property="og:type" content="website"/>
		<meta property="og:url" content="https://kyren.codes/"/>
		<meta property="og:image" content="https://kyren.codes/public/image.png"/>
		<meta property="og:image:alt" content="a cyan sphere with a dark background"/>
		<meta property="og:site_name" content="Kyren's Website"/>
		<script src="/public/copy.js" defer></script>
		<script src="/public/theme.js" defer></script>
		<script src="/public/scrollbar.js" defer></script>
		<script src="/public/my_uptime.js" defer></script>
		<script src="/public/footnotes.js" defer></script>
		<link rel="preload" href="/public/styles/style.css" as="style"/>
		<link rel="stylesheet" href="/public/styles/style.css"/>
		{ children... }
	</head>
}

func Choose(chooseA bool, a string, b string) string {
	if chooseA {
		return a
	} else {
		return b
	}
}

templ BlogItem(header string, blog Blog, extra string) {
	@TerminalBorderForBlog(header, blog.Date.Format("January 2, 2006"), Choose(header == "", "bg-black/20 hover:bg-white/5 transition-colors duration-150", "")+" "+extra, header == "") {
		<span class="cursor-pointer group block">
			<a href={ templ.SafeURL("/blogs/" + blog.Slug) } class="no-underline hover:no-underline">
				<h1 class="text-[130%] font-bold text-(--accent) group-hover:underline">
					{ blog.Title }
				</h1>
				<p class="text-(--secondary)">{ blog.Desc }</p>
			</a>
		</span>
	}
}

templ Link(href string, newTab bool) {
	<a
		href={ templ.SafeURL(href) }
		if newTab {
			target="_blank"
			rel="noopener noreferrer"
		}
	>
		{ children... }
	</a>
}

templ TerminalStack(joined bool, extra string) {
	<div class={ "flex flex-col min-h-0", templ.KV("[&>*+*]:mt-[-0.1rem]", joined), templ.KV("gap-4", !joined), extra }>
		{ children... }
	</div>
}

templ TerminalBorderForBlog(header string, footer string, extra string, enable bool) {
	if enable {
		<div class={ "relative flex px-3.5 py-(--ypad) pt-[calc(var(--ypad)+0.0625rem)] [--ypad:var(--border-py,0.875rem)] border-[0.1rem] border-solid border-[color:var(--alt)]", extra }>
			<span class="absolute px-[0.625rem] text-[1rem] left-[0.625rem] top-[-0.75rem] bg-[var(--text)] text-[color:var(--alt)]">{ header }</span>
			<span class="absolute px-[0.625rem] text-[0.6rem] left-[0.625rem] bottom-[-0.55rem] bg-[var(--background)] border-[0.05rem] text-(--alt)">{ footer }</span>
			{ children... }
		</div>
	} else {
		@TerminalBorder(header, footer, extra) {
			{ children... }
		}
	}
}

templ TerminalBorder(header string, footer string, extra string) {
	// <div class={ "relative flex px-3.5 py-(--ypad) pt-[calc(var(--ypad)+0.0625rem)] [--ypad:var(--border-py,0.875rem)] border-[0.1rem] border-solid border-[color:var(--alt)]", extra }>
	// 	<span class="absolute px-[0.625rem] text-[1rem] left-[0.625rem] top-[-0.75rem] text-[color:var(--alt)] bg-[linear-gradient(to_bottom,var(--background),var(--cmp-bg,transparent))]">{ header }</span>
	// 	<span class="absolute px-[0.625rem] text-[1rem] left-[0.625rem] bottom-[-0.75rem] text-[color:var(--alt)] bg-[linear-gradient(to_bottom,#181825,var(--background))]">{ footer }</span>
	// 	{ children... }
	// </div>
	<div class={ "relative flex px-3.5 py-(--ypad) pt-[calc(var(--ypad)+0.0625rem)] [--ypad:var(--border-py,0.875rem)] border-[0.1rem] border-solid border-(--alt)", extra }>
		<span class="absolute px-[0.625rem] text-[1rem] left-[0.625rem] top-[-0.75rem] bg-[var(--background)] text-[color:var(--alt)]">{ header }</span>
		<span class="absolute px-[0.625rem] text-[1rem] left-[0.625rem] bottom-[-0.75rem] bg-[var(--background)] text-[color:var(--alt)]">{ footer }</span>
		{ children... }
	</div>
}

templ CopyIcon() {
	<span class="block group-data-[copied]/copy:hidden">
		@IconCopy("text-[#ffffff]")
	</span>
	<span class="hidden group-data-[copied]/copy:block">
		@IconCheckmark("text-[#46d46c]")
	</span>
}

templ TerminalBorderWithCopy(header string, footer string, extra string, text string, href string, showLabel bool) {
	@TerminalBorder(header, footer, extra) {
		<div data-copy-scope class="group/copy flex w-full items-center justify-between gap-4">
			if href != "" {
				<a href={ templ.SafeURL(href) } class="wrap-anywhere">
					{ children... }
				</a>
			} else {
				<span data-copy={ text } class="cursor-pointer wrap-anywhere">
					{ children... }
				</span>
			}
			<span class="relative shrink-0">
				if showLabel {
					<span class="hidden group-data-copied/copy:block absolute right-full top-1/2 -translate-y-1/2 mr-2 px-[0.4rem] whitespace-nowrap bg-(--background) text-(--primary)">copied</span>
				}
				<button type="button" data-copy={ text } aria-label="copy" class="block p-[0.4rem] rounded-[0.4rem] cursor-pointer transition-colors hover:bg-(--alt)/25 group-data-copied/copy:bg-(--primary)/25!">
					@CopyIcon()
				</button>
			</span>
		</div>
	}
}

templ CopyPre(text string, preClass string) {
	<button type="button" data-copy={ text } class="group relative shrink-0 cursor-pointer text-left rounded-[0.4rem] p-[0.4rem] -m-[0.4rem] transition-colors hover:bg-(--alt)/25 data-copied:bg-(--primary)/25! data-copied:animate-[bump_0.25s]">
		<pre class={ preClass }>
			{ children... }
		</pre>
		<span class="hidden group-data-copied:block absolute right-[0.6rem] top-[0.6rem] px-[0.4rem] bg-(--background) text-(--primary) text-[0.8rem]">copied</span>
	</button>
}

templ NavLink(href string, label string) {
	<a href={ templ.SafeURL(href) } class="text-(--primary) hover:text-(--accent)">{ label }</a>
}

templ Nav(path string) {
	<nav class="flex justify-between gap-10 p-4 mb-6 border-[0.125rem] border-(--alt) text-[1.375rem]">
		<span>{ path }</span>
		<span class="flex gap-[1ch]">
			@NavLink("/", "home")
			for _, dir := range []string{"projects", "blogs"} {
				@NavLink("/"+dir, dir)
			}
			@NavLink("/shell", "shell")
		</span>
	</nav>
}

templ TerminalLayout(style Style, path string) {
	<!DOCTYPE html>
	<html lang="en" style={ styleToCss(style) }>
		@HeadComponent(path, "My personal website")
		<body>
			<main class="flex flex-col w-[75rem] h-[40rem] p-8 border-[0.2rem] border-(--text) overflow-hidden text-[1.125rem]">
				@Nav(path)
				{ children... }
			</main>
		</body>
	</html>
}

const fingerprint = `+--[ED25519 256]--+
|       +. ..  +.B|
|      + o..o . BB|
|     ..o oo.o =+E|
|     ... oo. + o.|
|      . S .   =  |
|  .  .   +   o   |
| o    o o .      |
|  oo .o+ +       |
|  ++ooo+=        |
+----[SHA256]-----+`
const sshKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO7P9K9D5RkBk+JCRRS6AtHuTAc6cRpXfRfRMg/Kyren"

templ HomePage(style Style, latestBlog *Blog) {
	@TerminalLayout(style, "/home/kyren/") {
		<div class={ "grid grid-cols-[29%_1fr] gap-x-8 flex-1 min-h-0", templ.KV("gap-y-4", !false) }>
			<div class="flex flex-col min-h-0 [--border-py:0.75rem]">
				@TerminalStack(true, "") {
					@TerminalBorder("Profile", "", "[--border-py:0.875rem]") {
						<div class="flex items-center gap-4 h-38">
							<img src="/public/favicon.svg" alt="picture" class="h-full object-cover"/>
							@CopyPre(sshKey, "shrink-0 text-[0.675rem] leading-[1.32]") {
								{ fingerprint }
							}
						</div>
					}
					@TerminalBorderWithCopy("Email", "", "", "contact@kyren.codes", "mailto:contact@kyren.codes", false) {
						contact@kyren.codes
					}
					@TerminalBorder("Git Repos (main)", "", "") {
						@Link("https://git.kyren.codes", true) {
							git.kyren.codes
						}
					}
					@TerminalBorder("GitHub (secondary)", "", "") {
						@Link("https://github.com/kyren223", true) {
							github.com/Kyren223
						}
					}
					@TerminalBorder("Discord", "", "") {
						@Link("https://discord.com/users/481884415090229258", true) {
							Kyren223
						}
					}
				}
			</div>
			<div class="flex flex-col gap-10 min-h-0 select-text">
				@TerminalBorder("Status", "", "") {
					<div class="flex gap-[1ch] text-[1rem]">
						<span>Working on</span>
						<span>
							@Link("/projects/krypton", false) {
								Krypton
							}
						</span>
						<span>|</span>
						<span>Learning Langdev & Compiler Design</span>
						<span>|</span>
						<span>Available for hire</span>
					</div>
				}
				@TerminalBorder("About Me", "", "") {
					Hi! I'm Kyren, a softwarea engineer and game developer.
					I love working with low level languages and learning things deeply.
					I am also a terminal nerd and Linux enthusiast who uses NVIM btw.
					And when I am not coding, I am most likely playing video games,
					watching Anime, or solving Rubik's cubes fast.
				}
				@BlogItem("Latest Blog Post", *latestBlog, "")
			</div>
			@TerminalBorderWithCopy("SSH Key", "", footerClass(false), sshKey, "", true) {
				{ sshKey }
			}
		</div>
	}
}

func footerClass(connected bool) string {
	style := "col-span-2 select-text [--border-py:0.5rem]"
	if connected {
		style += " mb-[0.30rem]"
	}
	return style
}

type Project struct {
	Slug     string
	Title    string
	Category string
	Desc     string
	Icon     templ.Component
	Tags     []ProjectTag
	Links    []ProjectLink
	Link     string
}

type ProjectTag struct {
	Name  string
	Color string
}

type ProjectLink struct {
	Icon  templ.Component
	Label string
	URL   string
}

type FlagshipInfo struct {
	Downloads []Download
	Version   string
	Stats     []Stat
	Snippet   string
}

type Download struct {
	Label   string // "Linux", "Windows"
	URL     string
	Size    string // "42 MB"
	Enabled bool
}

type Stat struct {
	Label string
	Value string
}

var versionBeforeDownloads = false

const flagshipClasses = "[--border-py:1.25rem] border-(--accent)! bg-white/[0.03] shadow-[0_0_1.5rem_color-mix(in_srgb,var(--accent)_25%,transparent)] bg-black/20 hover:bg-white/10 transition-colors duration-150"

templ FlagshipProject(project Project, extra string) {
	@TerminalBorder("", "", flagshipClasses+" "+extra) {
		<div class="flex gap-8 w-full">
			<div class="flex flex-col gap-4 flex-1 min-w-0">
				<div class="flex flex-wrap items-baseline gap-x-[1ch] gap-y-[0.4rem]">
					@project.Icon
					<a href={ templ.SafeURL("/projects/" + project.Slug) } class="no-underline text-[170%] font-bold text-(--accent) after:absolute after:inset-0 after:z-0">{ project.Title }</a>
					<span class="text-[85%] text-(--primary)">{ project.Category }</span>
					for _, tag := range project.Tags {
						<code class={ "text-[75%] px-[0.4rem] inline-block rounded-[0.3rem] border-[0.01rem] bg-(--alt)/25" + " " + tag.Color }>{ tag.Name }</code>
					}
					<span class="ml-auto flex items-center self-center relative z-10">
						for _, link := range project.Links {
							@IconLink(link.URL, link.Label, "") {
								@link.Icon
							}
						}
					</span>
				</div>
				<p class="leading-relaxed max-w-3xl">{ project.Desc }</p>
				if len(flagship.Downloads) > 0 || flagship.Version != "" {
					<div class="flex flex-wrap items-center gap-x-4 gap-y-2 relative z-10">
						if versionBeforeDownloads {
							@VersionTag(project)
						}
						for _, d := range flagship.Downloads {
							@DownloadButton(d)
						}
						if !versionBeforeDownloads {
							@VersionTag(project)
						}
					</div>
				}
				if len(flagship.Stats) > 0 {
					<div class="flex flex-wrap gap-x-[2rem] gap-y-[0.4rem] text-[85%]">
						for _, stat := range flagship.Stats {
							<span class="flex gap-[1ch]">
								<span class="font-bold text-(--primary)">{ stat.Value }</span>
								<span class="text-(--alt)">{ stat.Label }</span>
							</span>
						}
					</div>
				}
			</div>
			if flagship.Snippet != "" {
				<div class="shrink-0 self-start flex flex-col gap-[0.5rem] p-[1rem] rounded-[0.4rem] bg-black/30 relative z-10">
					<span class="text-[75%] text-(--alt)">example</span>
					@CopyPre(flagship.Snippet, "text-[80%] leading-[normal]") {
						{ flagship.Snippet }
					}
				</div>
			}
		</div>
	}
}

templ VersionTag(project Project) {
	if flagship.Version != "" {
		<span class="flex items-baseline gap-[1ch] text-[85%]">
			<code class="text-[#46d46c]">{ flagship.Version }</code>
			// <a href={ templ.SafeURL("/projects/" + project.Slug + "#changelog") } class="text-(--alt) hover:underline">changelog</a>
		</span>
	}
}

templ DownloadButton(download Download) {
	<a
		if download.Enabled {
			href={ templ.SafeURL(download.URL) }
		}
		class={
			"no-underline inline-flex items-center gap-[1ch] px-[0.6rem] py-[0.1rem] rounded-[0.4rem] border-[0.1rem] border-solid text-[85%] transition-colors",
			templ.KV("border-(--secondary)/60 text-(--secondary) hover:bg-(--secondary)/15", download.Enabled),
			templ.KV("border-(--alt)/30 text-(--alt)/80 bg-white/2", !download.Enabled),
		}
	>
		if download.Enabled {
			@IconArchive("text-(--secondary)")
		} else {
			@IconArchive("text-(--alt)")
		}
		<span>{ download.Label }</span>
		if download.Size != "" {
			<span class="text-(--alt)">{ download.Size }</span>
		}
	</a>
}

templ IconArchive(color string) {
	@Icon(color) {
		<rect width="20" height="5" x="2" y="3" rx="1"></rect>
		<path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"></path>
		<path d="M10 12h4"></path>
	}
}

templ IconLink(href string, label string, extra string) {
	<a href={ templ.SafeURL(href) } target="_blank" rel="noopener noreferrer" aria-label={ label } title={ label } class={ "text-[90%] block p-[0.2rem] rounded-[0.4rem] transition-colors hover:bg-(--alt)/25" + " " + extra }>
		{ children... }
	</a>
}

templ IconGit(color string) {
	@Icon(color) {
		<line x1="6" x2="6" y1="3" y2="15"></line>
		<circle cx="18" cy="6" r="3"></circle>
		<circle cx="6" cy="18" r="3"></circle>
		<path d="M18 9a9 9 0 0 1-9 9"></path>
	}
}

templ IconCheckmark(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check preview-icon"><path d="M20 6 9 17l-5-5"></path></svg>
	}
}

templ IconCopy(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy preview-icon"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path></svg>
	}
}

templ IconGithub(color string) {
	@Icon(color) {
		<path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"></path>
		<path d="M9 18c-4.51 2-5-2-7-2"></path>
	}
}

templ IconExternal(color string) {
	@Icon(color) {
		<path d="M15 3h6v6"></path>
		<path d="M10 14 21 3"></path>
		<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
	}
}

templ IconKrypton() {
	@Icon("text-[#00f1ff] scale-150") {
		<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="24" height="24" fill="none" stroke="currentColor">
			<!-- Outer Circle -->
			<circle cx="50" cy="50" r="42" stroke-width="6"></circle>
			<!-- Inner Dot -->
			<circle cx="50" cy="50" r="16" fill="currentColor" stroke="none"></circle>
		</svg>
	}
	// { "\uf192" }
}

func projectURL(p Project) string {
	if p.Link != "" {
		return p.Link
	}
	return "/projects/" + p.Slug
}

templ ProjectItem(project Project, extra string) {
	<div>
		@TerminalBorder("", "", "[--border-py:0.25rem] py-2 text-[80%] bg-black/20 hover:bg-white/5 transition-colors duration-150"+" "+extra) {
			<div class="flex flex-col gap-[0.0625rem] w-full">
				<div class="flex flex-wrap items-baseline gap-x-[1ch] gap-y-[0.4rem]">
					@project.Icon
					<a
						href={ templ.SafeURL(projectURL(project)) }
						if project.Link != "" {
							target="_blank"
							rel="noopener noreferrer"
						}
						class="text-[130%] font-bold text-(--accent) after:absolute after:inset-0 after:z-0"
					>{ project.Title }</a>
					<span class="text-[80%] text-(--primary)">{ project.Category }</span>
					for _, tag := range project.Tags {
						<code class={ "text-[75%] px-[0.4rem] inline-block rounded-[0.3rem] border-[0.01rem] bg-(--alt)/25" + " " + tag.Color }>{ tag.Name }</code>
					}
					// for _, tag := range project.Tags {
					//     <code class="text-[75%] px-[0.4rem] inline-block rounded-[0.3rem] bg-(--extra)/70 text-(--background)">{ tag }</code>
					// }
					<span class="ml-auto flex items-center self-center relative z-10">
						for _, link := range project.Links {
							@IconLink(link.URL, link.Label, "") {
								@link.Icon
							}
						}
					</span>
				</div>
				<p class="text-[95%]">{ project.Desc }</p>
			</div>
		}
	</div>
}

func DoubleProject(project Project) Project {
	project.Desc += project.Desc
	return project
}

templ ProjectsPage(style Style, projects []Project, pinned int) {
	@TerminalLayout(style, "/home/kyren/projects") {
		@FlagshipProject(projects[0], "mb-[1.5rem]")
		@ScrollBox("") {
			@TerminalStack(false, "mt-[0.5rem]") {
				for i := 0; i < 1; i++ {
					for i, project := range projects[1:] {
						if i < pinned {
							@ProjectItem(project, "my-[-0.15rem] border-(--text)")
						} else {
							@ProjectItem(project, "my-[-0.15rem]")
						}
					}
				}
			}
		}
	}
}

templ NotFoundPage(style Style, path string) {
	@TerminalLayout(style, path) {
		@TerminalStack(true, "") {
			@TerminalBorder("Shell", "", "") {
				<span>
					<p>$ cd ~{ path }</p>
					<p class="pt-3">"{ path[1:] }": No such file or directory (os error 2) </p>
				</span>
			}
			@TerminalBorder("", "", "") {
				<span>
					<div class="gap-[1ch]">
						<span>{ ">" }</span>
						<span class="text-(--secondary)">
							@Link("javascript:history.back()", false) {
								{ "cd -" }
							}
						</span>
						<span class="text-(--alt)">
							# Previous page
						</span>
					</div>
					<div class="gap-[1ch]">
						<span>{ ">" }</span>
						<span class="text-(--secondary)">
							@Link("/", false) {
								{ "cd $HOME" }
							}
						</span>
					</div>
				</span>
			}
		}
	}
}

templ ScrollBox(extra string) {
	<div data-scrollbox class={ "flex flex-1 min-h-0", extra }>
		<div data-scroll-area class="flex-1 min-w-0 overflow-y-auto border-[0.1rem] border-solid border-(--alt) p-[1rem] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
			{ children... }
		</div>
		<div data-scroll-track class="relative w-8 -ml-[0.1rem] border-[0.1rem] border-solid border-(--alt)">
			<div data-scroll-thumb class="absolute inset-x-[0.3rem] bg-(--secondary) cursor-grab touch-none"></div>
		</div>
	</div>
}

templ BlogsPage(style Style, blogs []Blog) {
	@TerminalLayout(style, "/home/kyren/blogs") {
		@TerminalBorder("Shell", "", "mb-[1rem]") {
			$ ls -lh ~/blogs
		}
		@ScrollBox("") {
			@TerminalStack(false, "mt-[0.5rem]") {
				for i := 0; i < 1; i++ {
					for _, blog := range blogs {
						@BlogItem("", blog, "mb-[1rem]")
					}
				}
			}
		}
	}
}

type FetchRow struct {
	Icon  templ.Component
	Color string // tailwind text color class, used for the icon and label
	Label string
	Value string
}

templ IconMonitor(color string) {
	@Icon(color) {
		<rect width="20" height="14" x="2" y="3" rx="2"></rect>
		<line x1="8" x2="16" y1="21" y2="21"></line>
		<line x1="12" x2="12" y1="17" y2="21"></line>
	}
}

templ IconTerminal(color string) {
	@Icon(color) {
		<polyline points="4 17 10 11 4 5"></polyline>
		<line x1="12" x2="20" y1="19" y2="19"></line>
	}
}

templ IconCode(color string) {
	@Icon(color) {
		<polyline points="16 18 22 12 16 6"></polyline>
		<polyline points="8 6 2 12 8 18"></polyline>
	}
}

templ IconCpu(color string) {
	@Icon(color) {
		<rect width="16" height="16" x="4" y="4" rx="2"></rect>
		<rect width="6" height="6" x="9" y="9" rx="1"></rect>
		<path d="M15 2v2M15 20v2M2 15h2M2 9h2M20 15h2M20 9h2M9 2v2M9 20v2"></path>
	}
}

templ IconScriptLang(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-file-terminal preview-icon"><path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"></path><path d="M14 2v5a1 1 0 0 0 1 1h5"></path><path d="m8 16 2-2-2-2"></path><path d="M12 18h4"></path></svg>
	}
}

templ IconEditor(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-pen preview-icon"><path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"></path></svg>
	}
}

templ IconDebugger(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bug-off preview-icon"><path d="M12 20v-8"></path><path d="M12.656 7H14a4 4 0 0 1 4 4v1.344"></path><path d="M14.12 3.88 16 2"></path><path d="M17.123 17.123A6 6 0 0 1 6 14v-3a4 4 0 0 1 1.72-3.287"></path><path d="m2 2 20 20"></path><path d="M21 5a4 4 0 0 1-3.55 3.97"></path><path d="M22 13h-3.344"></path><path d="M3 21a4 4 0 0 1 3.81-4"></path><path d="M3 5a4 4 0 0 0 3.55 3.97"></path><path d="M6 13H2"></path><path d="m8 2 1.88 1.88"></path><path d="M9.712 4.06A3 3 0 0 1 15 6v1.13"></path></svg>
	}
}

templ IconKeyboard(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-keyboard preview-icon"><path d="M10 8h.01"></path><path d="M12 12h.01"></path><path d="M14 8h.01"></path><path d="M16 12h.01"></path><path d="M18 8h.01"></path><path d="M6 8h.01"></path><path d="M7 16h10"></path><path d="M8 12h.01"></path><rect width="20" height="16" x="2" y="4" rx="2"></rect></svg>
	}
}

templ IconUptime(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clock preview-icon"><circle cx="12" cy="12" r="10"></circle><path d="M12 6v6l4 2"></path></svg>
	}
}

templ IconEko(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-wifi preview-icon"><path d="M12 20h.01"></path><path d="M2 8.82a15 15 0 0 1 20 0"></path><path d="M5 12.859a10 10 0 0 1 14 0"></path><path d="M8.5 16.429a5 5 0 0 1 7 0"></path></svg>
	}
}

templ IconTrident(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide preview-icon">
			<path d="m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8"></path>
			<path d="M19 5 2.1 21.9"></path>
		</svg>
	}
}

templ IconDotfiles(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-settings preview-icon"><path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"></path><circle cx="12" cy="12" r="3"></circle></svg>
	}
}

templ IconVideo(color string) {
	@Icon(color) {
		// <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-play preview-icon"><path d="M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z"></path><circle cx="12" cy="12" r="10"></circle></svg>
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-monitor-play preview-icon"><path d="M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z"></path><path d="M12 17v4"></path><path d="M8 21h8"></path><rect x="2" y="3" width="20" height="14" rx="2"></rect></svg>
	}
}

templ IconJetbrains(color string) {
	@Icon(color) {
		<svg fill="none" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
			<defs>
				<linearGradient id="_R_34j5_" x1="0.85" x2="62.62" y1="62.72" y2="1.81" gradientUnits="userSpaceOnUse">
					<stop stop-color="#FF9419"></stop>
					<stop offset="0.43" stop-color="#FF021D"></stop>
					<stop offset="0.99" stop-color="#E600FF"></stop>
				</linearGradient>
			</defs>
			<path fill="url(#_R_34j5_)" d="M20.34 3.66 3.66 20.34A12.5 12.5 0 0 0 0 29.18V59c0 2.76 2.24 5 5 5h29.82c3.32 0 6.49-1.32 8.84-3.66l16.68-16.68c2.34-2.34 3.66-5.52 3.66-8.84V5c0-2.76-2.24-5-5-5H29.18c-3.32 0-6.49 1.32-8.84 3.66"></path>
			<path fill="#000" d="M48 16H8v40h40z"></path>
			<path fill="#fff" d="M30 47H13v4h17z"></path>
		</svg>
	}
}

templ IconDocs(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-book-open preview-icon"><path d="M12 5v16"></path><path d="M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z"></path></svg>
	}
}

templ IconReleases(color string) {
	@Icon(color) {
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-tags preview-icon"><path d="M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z"></path><path d="M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193"></path><circle cx="10.5" cy="6.5" r=".5" fill="currentColor"></circle></svg>
	}
}

func row(icon func(color string) templ.Component, color, label, value string) FetchRow {
	return FetchRow{Icon: icon(color), Color: color, Label: label, Value: value}
}

var fetchRows = []FetchRow{
	// row(IconTerminal, "text-(--secondary)", "Terminal", "Ghostty & Zsh"),
	row(IconCode, "text-(--accent)", "Main Language", "C"),
	row(IconScriptLang, "text-(--accent)", "Scripting Langs", "Go and Python"),
	row(IconDebugger, "text-[#F16265]", "Debugger", "Raddebugger"),
	row(IconMonitor, "text-[#54D7A9]", "Operating System", "Fedora KDE Linux"),
	row(IconEditor, "text-[#54D7A9]", "Text Editor", "Neovim"),
	row(IconUptime, "text-[#D8C44B]", "Uptime", "Asleep"),
	// row(IconCpu, "--extra", "Hardware", "..."),
}

func branch(i, n int) string {
	switch {
	case n == 1:
		return "─"
	case i == 0:
		return "┌"
	case i == n-1:
		return "└"
	default:
		return "├"
	}
}

templ Fastfetch(rows []FetchRow) {
	<div
		style="
		display: grid;
		grid-template-columns: auto auto auto 1fr;
		align-items: center;
		column-gap: 1ch;
		line-height: normal;
	"
	>
		for i, row := range rows {
			<span class="text-(--alt)">{ branch(i, len(rows)) }</span>
			@row.Icon
			<span class={ row.Color, "font-bold" }>{ row.Label }</span>
			<span id={ row.Label }>{ row.Value }</span>
		}
	</div>
}

templ Icon(color string) {
	<svg width="1.1em" height="1.1em" class={ "shrink-0", Color(color), "self-center" } viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
		{ children... }
	</svg>
}

templ BlogPage(style Style, blog Blog, prev *Blog, next *Blog) {
	@TerminalLayout(style, "/home/kyren/blogs/"+blog.Slug) {
		@ScrollBox("") {
			@BlogItem("", blog, "mb-[1rem]")
			<article class="prose select-text font-(family-name:--font-normal) text-[17.6px] leading-[1.7]">
				@templ.Raw(blog.HTML)
			</article>
			<div class="grid grid-cols-2 gap-x-[1rem] mt-[1rem]">
				@BlogNav("Previous Blog", prev, "")
				@BlogNav("Next Blog", next, "")
			</div>
		}
	}
}

templ BlogNav(label string, blog *Blog, extra string) {
	if blog != nil {
		@TerminalBorder(label, "", "min-w-0 "+extra) {
			<a href={ templ.SafeURL("/blogs/" + blog.Slug) } class="block min-w-0 truncate">vim ~/blogs/{ blog.Slug }</a>
		}
	} else {
		<div></div>
	}
}

templ ShellPage(style Style) {
	@TerminalLayout(style, "/bin/bash") {
		@ScrollBox("") {
			<div data-shell class="flex flex-col gap-[1rem]">
				<div id="shell-history" class="flex flex-col gap-[1rem]">
					@ShellEntry("fastfetch", Fastfetch(fetchRows))
				</div>
				<div data-shell-prompt class="flex gap-[1ch]">
					<span class="shrink-0 text-(--primary)">$</span>
					<div class="relative flex-1">
						<input data-shell-input type="text" class="block w-full bg-transparent outline-none caret-transparent" autocomplete="off" autocapitalize="off" spellcheck="false"/>
						<span data-shell-caret class="absolute inset-y-0 w-[1ch] flex items-center whitespace-pre bg-(--text) text-(--background) pointer-events-none"></span>
					</div>
				</div>
			</div>
		}
		<script src="/public/shell.js" defer></script>
	}
}

templ ShellLines(lines []string) {
	<div class="flex flex-col">
		for _, line := range lines {
			<span>{ line }</span>
		}
	</div>
}

templ ShellEntry(cmd string, output templ.Component) {
	@TerminalBorder("$ "+cmd, "", "") {
		<div class="min-w-0 w-full">
			@output
		</div>
	}
}

templ ShellText(text string) {
	<p>{ text }</p>
}

templ ShellHelp(names []string) {
	<div class="flex flex-col">
		for _, name := range names {
			<span>{ name }</span>
		}
	</div>
}