Add html viewing
This commit is contained in:
@@ -3,6 +3,8 @@ package database
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/russross/blackfriday/v2"
|
||||
)
|
||||
|
||||
type Post struct {
|
||||
@@ -20,6 +22,11 @@ func (p *Post) GemtextPage() string {
|
||||
return fmt.Sprintf("# %s\n\n", p.Title) + p.GemtextContent.String
|
||||
}
|
||||
|
||||
func (p *Post) HTMLPage() string {
|
||||
extensions := blackfriday.CommonExtensions | blackfriday.HardLineBreak
|
||||
return fmt.Sprintf("<h1>%s</h1>\n%s", p.Title, blackfriday.Run([]byte(p.MarkdownContent), blackfriday.WithExtensions(extensions)))
|
||||
}
|
||||
|
||||
func GetPost(id int) (*Post, error) {
|
||||
db := GetDB()
|
||||
post := &Post{}
|
||||
|
||||
Reference in New Issue
Block a user