Compare commits

..

3 Commits

Author SHA1 Message Date
jolheiser 82a84f0c62
feat: switch from yaml to jsonnet
Signed-off-by: jolheiser <git@jolheiser.com>
2024-10-15 10:52:12 -05:00
jolheiser b3a82d9ddf
chore: remove helix-specific dir
This is handled by helix.drv now

Signed-off-by: jolheiser <git@jolheiser.com>
2024-10-15 10:27:58 -05:00
jolheiser dbf75afb9c
fix: remove binary
Signed-off-by: jolheiser <git@jolheiser.com>
2024-10-15 10:26:18 -05:00
9 changed files with 42 additions and 46 deletions

View File

@ -1,5 +0,0 @@
[[language]]
name = "templ"
language-id = "html"
language-servers = ["templ", "vscode-html-language-server", "tailwindcss-ls"]

View File

@ -4,7 +4,7 @@ My [personal website](https://jolheiser.com).
Uses [tailwind](https://tailwindcss.com/) (with [catppuccin btw](https://github.com/catppuccin/tailwindcss)) and [templ](https://github.com/a-h/templ) as a simple static page generator. Uses [tailwind](https://tailwindcss.com/) (with [catppuccin btw](https://github.com/catppuccin/tailwindcss)) and [templ](https://github.com/a-h/templ) as a simple static page generator.
Links are sourced from [links.yaml](links.yaml). Links are sourced from [links.jsonnet](links.jsonnet).
## Dev ## Dev

7
go.mod
View File

@ -5,5 +5,10 @@ go 1.21
require ( require (
git.jojodev.com/jolheiser/simpleicons v0.0.3 git.jojodev.com/jolheiser/simpleicons v0.0.3
github.com/a-h/templ v0.2.778 github.com/a-h/templ v0.2.778
gopkg.in/yaml.v3 v3.0.1 github.com/google/go-jsonnet v0.20.0
)
require (
gopkg.in/yaml.v2 v2.2.7 // indirect
sigs.k8s.io/yaml v1.1.0 // indirect
) )

View File

@ -1 +1 @@
sha256-EQclwPNQJxVv2sU5zBoeHjVIbezj7irqLVmoo2c/u5I= sha256-LCjIObTQdTuKwkM+0DESmaC5gWlbX8rGQkL1hn6Iy8Q=

10
go.sum
View File

@ -4,7 +4,13 @@ github.com/a-h/templ v0.2.778 h1:VzhOuvWECrwOec4790lcLlZpP4Iptt5Q4K9aFxQmtaM=
github.com/a-h/templ v0.2.778/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w= github.com/a-h/templ v0.2.778/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-jsonnet v0.20.0 h1:WG4TTSARuV7bSm4PMB4ohjxe33IHT5WVTrJSU33uT4g=
github.com/google/go-jsonnet v0.20.0/go.mod h1:VbgWF9JX7ztlv770x/TolZNGGFfiHEVx9G6ca2eUmeA=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=

Binary file not shown.

17
links.jsonnet 100644
View File

@ -0,0 +1,17 @@
local Link(name, url, icon=std.asciiLower(name)) = {
icon: icon,
name: name,
url: url,
};
{
links: [
Link('Git', 'https://git.jolheiser.com'),
Link('GitHub', 'https://github.com/jolheiser'),
Link('Gitea', 'https://gitea.com/jolheiser'),
Link('JoJoDev', 'https://git.jojodev.com/jolheiser', 'gitea'),
Link('Fediverse', 'https://social.jolheiser.com/@jolheiser', 'activitypub'),
Link('Bluesky', 'https://bsky.app/profile/jolheiser.com'),
Link('LinkedIn', 'https://linkedin.com/in/jolheiser'),
],
}

View File

@ -1,19 +0,0 @@
links:
- name: GitHub
url: https://github.com/jolheiser
icon: github
- name: Gitea
url: https://gitea.com/jolheiser
icon: gitea
- name: JoJoDev
url: https://git.jojodev.com/jolheiser
icon: gitea
- name: Fediverse
url: https://social.jolheiser.com/@jolheiser
icon: activitypub
- name: Bluesky
url: https://bsky.app/profile/jolheiser.com
icon: bluesky
- name: LinkedIn
url: https://linkedin.com/in/jolheiser
icon: linkedin

26
main.go
View File

@ -2,18 +2,17 @@ package main
import ( import (
"context" "context"
"io" "encoding/json"
"os" "os"
"git.jojodev.com/jolheiser/simpleicons" "git.jojodev.com/jolheiser/simpleicons"
"github.com/a-h/templ" "github.com/google/go-jsonnet"
"gopkg.in/yaml.v3"
) )
type Link struct { type Link struct {
Name string `yaml:"name"` Name string `json:"name"`
URL string `yaml:"url"` URL string `json:"url"`
IconName string `yaml:"icon"` IconName string `json:"icon"`
} }
func (l Link) Icon() simpleicons.Icon { func (l Link) Icon() simpleicons.Icon {
@ -31,15 +30,15 @@ var tailwindCSS = `
//go:generate tailwind-ctp -i ./dist/styles.css -o ./dist/styles.css --minify //go:generate tailwind-ctp -i ./dist/styles.css -o ./dist/styles.css --minify
func main() { func main() {
var links struct { var links struct {
Links []Link `yaml:"links"` Links []Link `json:"links"`
} }
fi, err := os.Open("links.yaml") vm := jsonnet.MakeVM()
data, err := vm.EvaluateFile("links.jsonnet")
if err != nil { if err != nil {
panic(err) panic(err)
} }
defer fi.Close() if err := json.Unmarshal([]byte(data), &links); err != nil {
if err := yaml.NewDecoder(fi).Decode(&links); err != nil {
panic(err) panic(err)
} }
@ -67,10 +66,3 @@ func main() {
panic(err) panic(err)
} }
} }
func SafeHTML(html string) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
_, err = io.WriteString(w, html)
return
})
}