29 lines
792 B
Go
29 lines
792 B
Go
package pages
|
|
|
|
import (
|
|
"embed"
|
|
"github.com/maddalax/htmgo/framework/h"
|
|
"github.com/maddalax/htmgo/framework/service"
|
|
"htmgo-site/internal/markdown"
|
|
)
|
|
|
|
func MarkdownPage(ctx *h.RequestContext, path string, id string) *h.Element {
|
|
return h.Div(
|
|
MarkdownContent(ctx, path, id),
|
|
h.Div(
|
|
h.Class("min-h-12"),
|
|
),
|
|
)
|
|
}
|
|
|
|
func MarkdownContent(ctx *h.RequestContext, path string, id string) *h.Element {
|
|
embeddedMd := ctx.Get("embeddedMarkdown").(*embed.FS)
|
|
renderer := service.Get[markdown.Renderer](ctx.ServiceLocator())
|
|
return h.Div(
|
|
h.If(id != "", h.Id(id)),
|
|
h.Div(
|
|
h.Class("w-full flex flex-col prose max-w-[95vw] md:max-w-3xl prose-code:text-black prose-p:my-1 prose:p-0 prose-li:m-0 prose-ul:m-0 prose-ol:m-0"),
|
|
h.Raw(renderer.RenderFile(path, embeddedMd)),
|
|
),
|
|
)
|
|
}
|