add webmention link to base.html

This commit is contained in:
Niko Abeler 2022-08-31 20:20:16 +02:00
parent 2309dfb0ce
commit 61a5435971
3 changed files with 20 additions and 0 deletions

View File

@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ .Title }}</title>
<link rel="stylesheet" href="/static/pico.min.css">
<link rel="webmention" href="{{ .User.WebmentionUrl }}">
<style>
header {
background-color: {{.HeaderColor}};

View File

@ -143,3 +143,17 @@ func TestRendersHeaderTitle(t *testing.T) {
t.Error("Header color not rendered. Got: " + result)
}
}
func TestRenderPostIncludesRelToWebMention(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost")
result, _ := owl.RenderPost(&post)
if !strings.Contains(result, "rel=\"webmention\"") {
t.Error("webmention rel not rendered. Got: " + result)
}
if !strings.Contains(result, "href=\""+user.WebmentionUrl()+"\"") {
t.Error("webmention href not rendered. Got: " + result)
}
}

View File

@ -36,6 +36,11 @@ func (user User) FullUrl() string {
return url
}
func (user User) WebmentionUrl() string {
url, _ := url.JoinPath(user.FullUrl(), "webmention/")
return url
}
func (user User) PostDir() string {
return path.Join(user.Dir(), "public")
}