basic blog page!

This commit is contained in:
ari melody 2025-04-02 23:04:09 +01:00
parent 8eb432539c
commit 1a8dc4d9ce
Signed by: ari
GPG key ID: 60B5F0386E3DDB7E
9 changed files with 209 additions and 0 deletions

86
view/blog.go Normal file
View file

@ -0,0 +1,86 @@
package view
import (
"html/template"
"net/http"
"time"
"arimelody-web/model"
"arimelody-web/templates"
"github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/html"
"github.com/gomarkdown/markdown/parser"
)
var mdRenderer = html.NewRenderer(html.RendererOptions{
Flags: html.CommonFlags | html.HrefTargetBlank,
})
func BlogHandler(app *model.AppState) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
blog := model.Blog{
Title: "hello world!~",
Description: "lorem ipsum yadda yadda something boobies babababababababa",
Visible: true,
Date: time.Now(),
AuthorID: "ari",
Markdown:
`
# hello, world!
i'm ari!
she/her 🏳🏳🌈💫🦆🇮🇪
i'm a musician, developer, streamer, youtuber, and probably a bunch of other things i forgot to mention!
you're very welcome to take a look around my little space on the internet here, or explore any of the other parts i inhabit!
if you're looking to support me financially, that's so cool of you!! if you like, you can buy some of my music over on bandcamp so you can at least get something for your money. thank you very much either way!! 💕
for anything else, you can reach me for any and all communications through ari@arimelody.me. if your message contains anything beyond a silly gag, i strongly recommend encrypting your message using my public pgp key, listed below!
thank you for stopping by- i hope you have a lovely rest of your day! 💫
## metadata
**my colours 🌈**
- primary: <span class="col-primary">#b7fd49</span>
- secondary: <span class="col-secondary">#f8e05b</span>
- tertiary: <span class="col-tertiary">#f788fe</span>
**my keys 🔑**
- pgp: [[link]](/keys/ari%20melody_0x92678188_public.asc)
- ssh (ed25519): [[link]](/keys/id_ari_ed25519.pub)
**where to find me 🛰**
- youtube
- twitch
- spotify
- bandcamp
- github
**projects i've worked on 🛠**
- catdance
- pride flag
- ipaddrgen
- impact meme
- OpenTerminal
- Silver.js
`,
}
// blog.Markdown += " <i class=\"end-mark\"></i>"
mdParser := parser.NewWithExtensions(parser.CommonExtensions | parser.AutoHeadingIDs)
md := mdParser.Parse([]byte(blog.Markdown))
blog.HTML = template.HTML(markdown.Render(md, mdRenderer))
templates.BlogTemplate.Execute(w, &blog)
})
}

34
view/blog.html Normal file
View file

@ -0,0 +1,34 @@
{{define "head"}}
<title>{{.Title}} - ari melody 💫</title>
<link rel="shortcut icon" href="/img/favicon.png" type="image/x-icon">
<meta name="description" content="{{.Description}}">
<meta property="og:title" content="{{.Title}}">
<meta property="og:type" content="article">
<meta property="og:url" content="www.arimelody.me/blog/{{.Date.Year}}/{{.GetMonth}}/{{.TitleNormalised}}">
<meta property="og:image" content="https://www.arimelody.me/img/favicon.png">
<meta property="og:site_name" content="ari melody">
<meta property="og:description" content="{{.Description}}">
<link rel="stylesheet" href="/style/main.css">
<link rel="stylesheet" href="/style/index.css">
<link rel="stylesheet" href="/style/blog.css">
{{end}}
{{define "content"}}
<main>
<article class="blog">
<h1 class="typeout">{{.Title}}</h1>
<p class="blog-date">Posted by <a href="/blog/{{.AuthorID}}">{{.AuthorID}}</a> @ {{.PrintDate}}</p>
<hr>
{{.HTML}}
<hr>
<!-- comments section here! -->
</article>
<script type="module" src="/script/blog.js"></script>
</main>
{{end}}