htmgo/htmgo-site/pages/docs.go

32 lines
725 B
Go
Raw Normal View History

2024-09-20 16:45:23 +00:00
package pages
import (
2024-09-20 18:25:14 +00:00
"embed"
2024-09-20 16:45:23 +00:00
"github.com/maddalax/htmgo/framework/h"
"htmgo-site/internal/dirwalk"
"htmgo-site/pages/base"
2024-09-23 19:41:43 +00:00
"htmgo-site/partials"
"strings"
2024-09-20 16:45:23 +00:00
)
func DocsPage(ctx *h.RequestContext) *h.Page {
2024-09-20 18:25:14 +00:00
assets := ctx.Get("embeddedMarkdown").(*embed.FS)
pages := dirwalk.WalkPages("md/docs", assets)
2024-09-20 16:45:23 +00:00
return h.NewPage(base.RootPage(
h.Div(
2024-09-23 19:41:43 +00:00
h.Class("flex gap-4 justify-center mb-12"),
partials.DocSidebar(pages),
h.Div(
h.Class("flex flex-col justify-center items-center mt-6 gap-12"),
h.List(pages, func(page *dirwalk.Page, index int) *h.Element {
return MarkdownContent(ctx, page.FilePath, strings.Join(page.Parts, "-"))
}),
),
h.Div(
h.Class("min-h-12"),
),
2024-09-20 16:45:23 +00:00
),
2024-09-23 19:41:43 +00:00
))
2024-09-20 16:45:23 +00:00
}