some more fixes
This commit is contained in:
parent
5ee5d956f0
commit
62599c22ea
2 changed files with 5 additions and 1 deletions
|
|
@ -11,10 +11,12 @@ import (
|
||||||
"github.com/yuin/goldmark/renderer/html"
|
"github.com/yuin/goldmark/renderer/html"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Renderer struct {
|
type Renderer struct {
|
||||||
cache map[string]string
|
cache map[string]string
|
||||||
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRenderer() *Renderer {
|
func NewRenderer() *Renderer {
|
||||||
|
|
@ -22,6 +24,8 @@ func NewRenderer() *Renderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Renderer) RenderFile(source string, system fs.FS) string {
|
func (r *Renderer) RenderFile(source string, system fs.FS) string {
|
||||||
|
r.lock.Lock()
|
||||||
|
defer r.lock.Unlock()
|
||||||
if val, ok := r.cache[source]; ok {
|
if val, ok := r.cache[source]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ func MarkdownContent(ctx *h.RequestContext, path string, id string) *h.Element {
|
||||||
h.Id(id),
|
h.Id(id),
|
||||||
),
|
),
|
||||||
h.Div(
|
h.Div(
|
||||||
h.Class("w-full flex flex-col prose max-w-[90vw] md:max-w-3xl lg:max-w-4xl prose-code:text-black prose-p:my-1 prose:p-0 prose-li:m-0 prose-ul:m-0 prose-ol:m-0"),
|
h.Class("w-full flex flex-col prose max-w-[90vw] md:max-w-xl md:px-4 lg:max-w-4xl xl:max-w-5xl prose-code:text-black prose-p:my-1 prose:p-0 prose-li:m-0 prose-ul:m-0 prose-ol:m-0"),
|
||||||
h.UnsafeRaw(renderer.RenderFile(path, embeddedMd)),
|
h.UnsafeRaw(renderer.RenderFile(path, embeddedMd)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue