diff --git a/web/articles.go b/web/articles.go index c61a237..5c4b49f 100644 --- a/web/articles.go +++ b/web/articles.go @@ -17,7 +17,7 @@ const ( //go:embed articles var articlesFS embed.FS -var articles map[string]article.Article = make(map[string]article.Article) +var articles map[string]*article.Article = make(map[string]*article.Article) // ArticleMetadata holds date, title and URL of an article used in articles list // on the Stuff page. @@ -49,7 +49,7 @@ func GetArticleMetadata() (meta []ArticleMetadata) { func GetArticle(name string) (*article.Article, error) { if artcl, ok := articles[name]; ok { - return &artcl, nil + return artcl, nil } meta, err := articlesFS.ReadFile("articles/" + name + articleMetaExtension) @@ -62,14 +62,9 @@ func GetArticle(name string) (*article.Article, error) { return nil, err } - artcl := article.Article{ - Body: markdown.ToHTML(md, nil, nil)} + articles[name], err = article.New(markdown.ToHTML(md, nil, nil), meta) - artcl.ParseMetadata(meta) - - articles[name] = artcl - - return &artcl, nil + return articles[name], err } func init() {