#13 GitHub Handle

This commit is contained in:
Niko Abeler 2022-09-08 21:28:05 +02:00
parent ecfcd84b82
commit a8998068ad
4 changed files with 27 additions and 1 deletions

View File

@ -76,6 +76,7 @@ var webmentionCmd = &cobra.Command{
return return
} }
processPost(user, &post) processPost(user, &post)
return
} }
posts, err := user.Posts() posts, err := user.Posts()

View File

@ -44,7 +44,12 @@
<nav> <nav>
<ul> <ul>
{{ if .UserConfig.TwitterHandle}} {{ if .UserConfig.TwitterHandle}}
<li><a href="https://twitter.com/{{.UserConfig.TwitterHandle}}" rel="me">@{{.UserConfig.TwitterHandle}} on Twitter</a></li> <li><a href="https://twitter.com/{{.UserConfig.TwitterHandle}}" rel="me">@{{.UserConfig.TwitterHandle}} on Twitter</a>
</li>
{{ end }}
{{ if .UserConfig.GitHubHandle}}
<li><a href="https://github.com/{{.UserConfig.GitHubHandle}}" rel="me">@{{.UserConfig.GitHubHandle}} on GitHub</a>
</li>
{{ end }} {{ end }}
</ul> </ul>
</nav> </nav>

View File

@ -44,6 +44,25 @@ func TestRenderTwitterHandle(t *testing.T) {
} }
func TestRenderGitHubHandle(t *testing.T) {
user := getTestUser()
config, _ := user.Config()
config.GitHubHandle = "testhandle"
user.SetConfig(config)
post, _ := user.CreateNewPost("testpost")
result, err := owl.RenderPost(&post)
if err != nil {
t.Error("Error rendering post: " + err.Error())
return
}
if !strings.Contains(result, "href=\"https://github.com/testhandle\" rel=\"me\"") {
t.Error("GitHub handle not rendered. Got: " + result)
}
}
func TestRenderPostHEntry(t *testing.T) { func TestRenderPostHEntry(t *testing.T) {
user := getTestUser() user := getTestUser()
post, _ := user.CreateNewPost("testpost") post, _ := user.CreateNewPost("testpost")

View File

@ -22,6 +22,7 @@ type UserConfig struct {
SubTitle string `yaml:"subtitle"` SubTitle string `yaml:"subtitle"`
HeaderColor string `yaml:"header_color"` HeaderColor string `yaml:"header_color"`
TwitterHandle string `yaml:"twitter_handle"` TwitterHandle string `yaml:"twitter_handle"`
GitHubHandle string `yaml:"github_handle"`
} }
func (user User) Dir() string { func (user User) Dir() string {