markdown on note

This commit is contained in:
Niko Abeler 2023-07-19 20:54:18 +02:00
parent c24f2cb9db
commit 93184589bf
4 changed files with 36 additions and 3 deletions

24
cmd/owl/media_test.go Normal file
View File

@ -0,0 +1,24 @@
package main
import (
"net/http/httptest"
"owl-blogs/test"
"testing"
"github.com/stretchr/testify/require"
)
func TestMediaWithSpace(t *testing.T) {
db := test.NewMockDb()
owlApp := App(db)
app := owlApp.FiberApp
_, err := owlApp.BinaryService.Create("name with space.jpg", []byte("111"))
require.NoError(t, err)
req := httptest.NewRequest("GET", "/media/name%20with%20space.jpg", nil)
resp, err := app.Test(req)
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode)
}

View File

@ -1,6 +1,10 @@
package entrytypes
import "owl-blogs/domain/model"
import (
"fmt"
"owl-blogs/domain/model"
"owl-blogs/render"
)
type Note struct {
model.EntryBase
@ -16,7 +20,11 @@ func (e *Note) Title() string {
}
func (e *Note) Content() model.EntryContent {
return model.EntryContent(e.meta.Content)
str, err := render.RenderTemplateToString("entry/Note", e)
if err != nil {
fmt.Println(err)
}
return model.EntryContent(str)
}
func (e *Note) MetaData() interface{} {

View File

@ -0,0 +1 @@
{{.MetaData.Content | markdown }}

View File

@ -1 +1 @@
{{.MetaData.Content}}
{{.MetaData.Content | markdown }}