feat: update site

This commit is contained in:
2024-11-22 15:02:29 -05:00
parent 4b1b6b4369
commit 79327510d7
9 changed files with 124 additions and 52 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"log/slog"
"net/http"
"path"
"sync"
)
@@ -44,15 +45,16 @@ func (h *handler) RequestsCounterMiddleware(next http.Handler) http.Handler {
func (h *handler) Ping(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Pong")
}
func (h *handler) Index(w http.ResponseWriter, r *http.Request) {
h.logger.Info(r.URL.Path)
if template, isOk := templates[r.URL.Path]; isOk {
if template, isOk := templates[path.Base(r.URL.Path)]; isOk {
h.logger.Info("Found template")
template.ExecuteTemplate(w, "base", nil)
} else {
h.logger.Info("default template")
templates["index.html"].ExecuteTemplate(w, "base", nil)
templates["index"].ExecuteTemplate(w, "base", nil)
}
}

View File

@@ -1,55 +1,77 @@
:root {
--font-family: "Comic Mono";
--line-height: 1.2rem;
--font-weight-normal: 500;
--font-weight-medium: 600;
--font-weight-bold: 800;
--font-family: "Comic Mono";
--line-height: 1.2rem;
--font-weight-normal: 500;
--font-weight-medium: 600;
--font-weight-bold: 800;
font-family: var(--font-family), monospace;
font-weight: var(--font-weight-normal);
font-size: 16px;
font-family: var(--font-family), monospace;
font-weight: var(--font-weight-normal);
font-size: 16px;
}
* {
box-sizing: border-box;
box-sizing: border-box;
}
body {
width: 100%;
margin: 0;
line-height: var(--line-height);
max-width: 100ch;
width: 100%;
margin: 0;
line-height: var(--line-height);
max-width: 100ch;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: calc(var(--line-height) * 2) 0 var(--line-height) 0;
font-weight: var(--font-weight-bold);
margin: calc(var(--line-height) * 2) 0 var(--line-height) 0;
font-weight: var(--font-weight-bold);
}
h1 {
font-size: 2rem;
margin-bottom: calc(var(--line-height) * 2);
text-transform: uppercase;
font-size: 2rem;
margin-bottom: calc(var(--line-height) * 2);
text-transform: uppercase;
}
h2 {
font-size: 1rem;
text-transform: uppercase;
font-size: 1rem;
text-transform: uppercase;
}
#grid {
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: linear-gradient(to right, #ccc 1px, transparent 1px),
linear-gradient(to bottom, #ccc 1px, transparent 1px);
background-size: 1ch var(--line-height); /* Adjust grid size */
background-position: top left;
margin: 0;
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: linear-gradient(to right, #ccc 1px, transparent 1px),
linear-gradient(to bottom, #ccc 1px, transparent 1px);
background-size: 1ch var(--line-height);
/* Adjust grid size */
background-position: top left;
margin: 0;
}
p {
margin-bottom: var(--line-height);
margin-bottom: var(--line-height);
}
li {
margin: 0;
padding: 0;
}
ul {
padding: 0 0 0 2ch;
margin: 0 0 var(--line-height);
list-style-type: square;
}
ul li ul {
margin-bottom: 0;
}

View File

@@ -7,6 +7,7 @@ import (
"html/template"
"io/fs"
"path"
"path/filepath"
"strings"
)
@@ -14,24 +15,28 @@ var templates map[string]*template.Template
func init() {
templates = make(map[string]*template.Template)
fs.WalkDir(templateContent, "templates", func(p string, d fs.DirEntry, err error) error {
fs.WalkDir(templateDir, "templates", func(p string, d fs.DirEntry, err error) error {
if d.IsDir() || !strings.HasSuffix(p, ".html") {
return nil
}
basePath := path.Base(p)
templates[basePath] = template.Must(template.ParseFS(templateContent, p, "templates/_layout.html.tmpl"))
fmt.Println(path.Base(p))
basePath := strings.TrimSuffix(path.Base(p), filepath.Ext(p))
templates[basePath] = template.Must(template.ParseFS(templateDir, p, "templates/_layout.html.tmpl"))
return nil
})
fmt.Printf("successfully parsed templates: ")
for k, t := range templates {
fmt.Printf("%s: %s \n", k, t.Name())
fmt.Println("Parsed templates")
for k, ts := range templates {
fmt.Printf("%s: ", k)
for _, t := range ts.Templates() {
fmt.Printf("%s ", t.Name())
}
fmt.Println()
}
fmt.Println()
}
//go:embed templates/*
var templateContent embed.FS
var templateDir embed.FS
//go:embed static/*
var staticContent embed.FS

View File

@@ -11,5 +11,8 @@
{{ template "content" .}}
<div id="grid"></div>
</body>
<footer>
Website design inspired by and shamelessly stolen from <a href="https://owickstrom.github.io/the-monospace-web/">The monospace web </a>
</footer>
</html>
{{ end }}

View File

@@ -1,12 +1,36 @@
{{ define "content" }}
<h1>Yadunand's Site WIP 🚧</h1>
<p>Body</p>
<h2>Header 2</h2>
<p>Body</p>
<h3>Header 3</h3>
<p>Body</p>
<h4>Header 4</h4>
<p>Body</p>
<h5>Header 5</h5>
<p></p>
<p>Hi, I'm Yadunand, a software engineer currently based in 🇨🇦, previously in 🇭🇰,🇦🇺,🇸🇬. I'm interested in how
companies build things that scale, and how infrastructure works in general. This site is built on the exploration of
that. Most of my work (including <a href="https://git.yadunut.dev/yadunut/yadunut.dev">this site</a>, and the <a
href="https://git.yadunut.dev/yadunut/homelab">infrastructure</a>) can be found on my <a
href="https://git.yadunut.dev/yadunut">gitea</a></p>
<h2>Currently</h2>
<ul>
<li>Software Engineer at <a href="https://endorhealth.com/">Endor Health</a>
<ul>
<li>React Native, Typescript</li>
<li>Python, flask</li>
</ul>
</li>
<li>Year 3 student at <a href="https://www.nus.edu.sg/">National University of Singapore</a></li>
<li>Exchange Student at <a href="https://www.utoronto.ca/">University of Toronto</a></li>
</ul>
<h2>Previously</h2>
<ul>
<li>Technology Intern at <a href="https://www.mwam.com/">Marshall Wace</a>
<ul>
<li>Python, FastAPI</li>
<li>React, Typescript</li>
</ul>
</li>
<li>Software Engineer at <a href="https://www.undertide.co/">Undertide</a></li>
<ul>
<li>React Native, Graphql, Typescript</li>
</ul>
</ul>
<h2>Contact Me</h2>
<p>I'm always happy to chat, feel free to reach out to me a @yadunut on (Twitter, Instagram, Telegram) or on <a href="mailto:me@yadunut.com">email</a></p>
{{ end }}

View File

@@ -0,0 +1,3 @@
{{ define "content" }}
<h1>Something goes here</h1>
{{ end }}