Eric Bower
·
18 Nov 24
main.go
1package main
2
3import (
4 "log/slog"
5 "math/rand"
6 "strconv"
7
8 "github.com/picosh/pdocs"
9)
10
11func main() {
12 pager := pdocs.Pager("./posts")
13 sitemap := &pdocs.Sitemap{
14 Children: []*pdocs.Sitemap{
15 {
16 Text: "Home",
17 Href: "/",
18 Page: pager("home.md"),
19 },
20 {
21 Text: "Sitemap",
22 Href: "/sitemap",
23 Page: pager("sitemap.md"),
24 },
25 {
26 Text: "Getting started",
27 Href: "/getting-started",
28 Page: pager("getting-started.md"),
29 },
30 {
31 Text: "Learn",
32 Href: "/learn",
33 Page: pager("learn.md"),
34 },
35 {
36 Text: "Controllers",
37 Href: "/controllers",
38 Page: pager("controllers.md"),
39 Children: []*pdocs.Sitemap{
40 {
41 Text: "Thunks",
42 Href: "/thunks",
43 Page: pager("thunks.md"),
44 },
45 {
46 Text: "Endpoints",
47 Href: "/endpoints",
48 Page: pager("endpoints.md"),
49 },
50 {
51 Text: "Dispatch",
52 Href: "/dispatch",
53 Page: pager("dispatch.md"),
54 },
55 },
56 },
57 {
58 Text: "Models",
59 Href: "/models",
60 Page: pager("models.md"),
61 Children: []*pdocs.Sitemap{
62 {
63
64 Text: "Store",
65 Href: "/store",
66 Page: pager("store.md"),
67 },
68 {
69 Text: "Schema",
70 Href: "/schema",
71 Page: pager("schema.md"),
72 },
73 {
74 Text: "Selectors",
75 Href: "/selectors",
76 Page: pager("selectors.md"),
77 },
78 },
79 },
80 {
81 Text: "React",
82 Href: "/react",
83 Page: pager("react.md"),
84 },
85 {
86 Text: "Guides & Concepts",
87 Children: []*pdocs.Sitemap{
88 {
89 Text: "Caching",
90 Href: "/caching",
91 Page: pager("caching.md"),
92 },
93 {
94 Text: "Dependent Queries",
95 Href: "/dependent-queries",
96 Page: pager("dependent.md"),
97 },
98 {
99 Text: "Middleware",
100 Href: "/middleware",
101 Page: pager("mdw.md"),
102 },
103 {
104 Text: "Loaders",
105 Href: "/loaders",
106 Page: pager("loaders.md"),
107 },
108 {
109 Text: "FX",
110 Href: "/fx",
111 Page: pager("fx.md"),
112 },
113 {
114 Text: "Error Handling",
115 Href: "/error-handling",
116 Page: pager("error-handling.md"),
117 },
118 {
119 Text: "Structured Concurrency",
120 Href: "/structured-concurrency",
121 Page: pager("structured-concurrency.md"),
122 },
123 {
124 Text: "Supervisors",
125 Href: "/supervisors",
126 Page: pager("supervisors.md"),
127 },
128 {
129 Text: "Testing",
130 Href: "/testing",
131 Page: pager("testing.md"),
132 },
133 {
134 Text: "Design Philosophy",
135 Href: "/design-philosophy",
136 Page: pager("design-philosophy.md"),
137 },
138 },
139 },
140 {
141 Text: "Resources",
142 Href: "/resources",
143 Page: pager("resources.md"),
144 },
145 },
146 }
147
148 logger := slog.Default()
149 config := &pdocs.DocConfig{
150 Logger: logger,
151 Sitemap: sitemap,
152 Out: "./public",
153 Tmpl: "./tmpl",
154 PageTmpl: "post.page.tmpl",
155 CacheId: strconv.Itoa(rand.Intn(10000)),
156 }
157
158 err := config.GenSite()
159 if err != nil {
160 panic(err)
161 }
162}