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,7 +4,7 @@ FROM golang:1.23-alpine as builder
WORKDIR /app
# Copy and download dependencies
COPY go.mod ./
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code

6
go.mod
View File

@@ -1,3 +1,9 @@
module git.yadunut.dev/yadunut/yadunut.dev
go 1.23.3
require (
github.com/yuin/goldmark v1.7.8 // indirect
github.com/yuin/goldmark-meta v1.1.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)

7
go.sum Normal file
View File

@@ -0,0 +1,7 @@
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc=
github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

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

@@ -9,15 +9,18 @@
font-weight: var(--font-weight-normal);
font-size: 16px;
}
* {
box-sizing: border-box;
}
body {
width: 100%;
margin: 0;
line-height: var(--line-height);
max-width: 100ch;
}
h1,
h2,
h3,
@@ -27,15 +30,18 @@ h6 {
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;
}
h2 {
font-size: 1rem;
text-transform: uppercase;
}
#grid {
position: absolute;
z-index: -1;
@@ -45,7 +51,8 @@ h2 {
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-size: 1ch var(--line-height);
/* Adjust grid size */
background-position: top left;
margin: 0;
}
@@ -53,3 +60,18 @@ h2 {
p {
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 }}