From 14a0272b185924eb708b1f90a5773fe18a1bbf66 Mon Sep 17 00:00:00 2001 From: MacRat Date: Thu, 20 Jun 2024 22:58:56 +0900 Subject: [PATCH] design: implement view-transition --- builder/template.go | 7 +++++++ templates/base.html | 2 +- templates/blog/index.html | 2 +- templates/blog/month.html | 2 +- templates/blog/post.html | 2 +- templates/blog/tagpage.html | 2 +- templates/blog/year.html | 2 +- templates/photos/detail.html | 1 + templates/photos/index.html | 1 + 9 files changed, 15 insertions(+), 6 deletions(-) diff --git a/builder/template.go b/builder/template.go index 88695703..786b48df 100644 --- a/builder/template.go +++ b/builder/template.go @@ -7,6 +7,8 @@ import ( "strconv" "strings" "sync" + "crypto/sha256" + "encoding/base64" ) type TemplateLoader struct { @@ -60,6 +62,11 @@ func NewTemplateLoader(basePath string) (*TemplateLoader, error) { "xmldecralation": func() template.HTML { return template.HTML(``) }, + "shorthash": func(s string) string { + hash := sha256.New() + hash.Write([]byte(s)) + return base64.URLEncoding.EncodeToString(hash.Sum(nil)[:8])[:8] + }, }) return &TemplateLoader{ diff --git a/templates/base.html b/templates/base.html index f4cf1bb4..b438f794 100644 --- a/templates/base.html +++ b/templates/base.html @@ -20,13 +20,13 @@ {{block "head" .}}{{end}}