2024-09-20 16:45:23 +00:00
|
|
|
package pages
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
|
"htmgo-site/internal/dirwalk"
|
2024-09-20 18:25:14 +00:00
|
|
|
"io/fs"
|
2024-09-20 16:45:23 +00:00
|
|
|
)
|
|
|
|
|
|
2024-09-20 18:25:14 +00:00
|
|
|
func RegisterMarkdown(app *echo.Echo, dir string, system fs.FS, handler func(ctx echo.Context, path string) error) {
|
|
|
|
|
for _, page := range dirwalk.WalkPages(dir, system) {
|
2024-09-20 16:45:23 +00:00
|
|
|
app.GET(page.RoutePath, func(ctx echo.Context) error {
|
|
|
|
|
return handler(ctx, page.FilePath)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|