Add html viewing

This commit is contained in:
Senad Uka
2023-08-05 10:58:20 +02:00
parent 517486689e
commit 39a0d3fe00
30 changed files with 11537 additions and 1 deletions

View File

@@ -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{}