htmgo/htmgo-site/pages/docs.go

68 lines
1.8 KiB
Go
Raw Normal View History

2024-09-20 16:45:23 +00:00
package pages
import (
"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"
"io/fs"
2024-09-20 16:45:23 +00:00
)
func DocsPage(ctx *h.RequestContext) *h.Page {
assets := ctx.Get("embeddedMarkdown").(fs.FS)
2024-09-20 18:25:14 +00:00
pages := dirwalk.WalkPages("md/docs", assets)
2024-09-20 16:45:23 +00:00
return h.NewPage(base.RootPage(
2024-09-27 02:15:04 +00:00
ctx,
2024-09-20 16:45:23 +00:00
h.Div(
2024-10-13 13:24:23 +00:00
h.Class("flex h-full"),
2024-09-28 03:45:42 +00:00
h.Aside(
2024-10-13 13:24:23 +00:00
h.Class("hidden md:block md:min-w-60 text-white overflow-y-auto"),
2024-09-28 03:45:42 +00:00
partials.DocSidebar(pages),
2024-09-23 19:41:43 +00:00
),
2024-10-13 13:24:23 +00:00
h.Div(
h.Class("flex flex-col flex-1 overflow-hidden"),
partials.NavBar(ctx, partials.NavBarProps{
Expanded: false,
ShowPreRelease: false,
}),
h.Main(
2024-09-28 03:45:42 +00:00
h.Div(
2024-10-13 13:24:23 +00:00
h.Class("w-full md:hidden bg-neutral-50 overflow-y-auto"),
partials.DocSidebar(pages),
2024-09-28 03:45:42 +00:00
),
2024-10-25 19:11:48 +00:00
h.Class("overflow-y-auto justify-center overflow-x-hidden pb-6 items-center w-full"),
2024-09-28 03:45:42 +00:00
h.Div(
2024-10-25 19:11:48 +00:00
h.Class("flex flex-col mx-auto"),
2024-10-13 13:24:23 +00:00
h.Div(
2024-10-25 19:11:48 +00:00
h.Class("flex flex-col justify-center items-center md:mt-6 mx-auto"),
2024-10-13 13:24:23 +00:00
h.List(pages, func(page *dirwalk.Page, index int) *h.Element {
anchor := partials.CreateAnchor(page.Parts)
return h.Div(
h.Class("border-b border-b-slate-300 w-full pb-8 p-4 md:px-0 -mb-2"),
MarkdownContent(ctx, page.FilePath, anchor),
h.Div(
h.Class("ml-4 pl-1 mt-2 bg-rose-200"),
h.If(
anchor == "core-concepts-partials",
2024-10-13 13:24:23 +00:00
h.GetPartial(partials.CurrentTimePartial, "load, every 1s"),
),
),
)
}),
),
h.Div(
h.Class("flex justify-center items-center mt-6"),
h.A(
h.Text("Back to Top"),
h.Class("py-2 px-3 bg-slate-800 rounded text-white"),
h.Href("#quick-start-introduction"),
),
2024-09-28 03:45:42 +00:00
),
),
),
2024-09-23 19:41:43 +00:00
),
2024-09-20 16:45:23 +00:00
),
2024-09-23 19:41:43 +00:00
))
2024-09-20 16:45:23 +00:00
}