feat: also parse folder content

This commit is contained in:
Max Richter
2025-10-04 13:16:16 +02:00
parent a5acef77a2
commit fa283d5dd7
4 changed files with 30 additions and 2 deletions

View File

@@ -1,3 +1,15 @@
module git.max-richter.dev/max/marka/server-new module git.max-richter.dev/max/marka/server-new
go 1.24.7 go 1.24.7
require git.max-richter.dev/max/marka/parser v0.0.0-20251003194139-ab81c980b590
require (
git.max-richter.dev/max/marka/registry v0.0.0-20250817132016-6db87db32567 // indirect
git.max-richter.dev/max/marka/renderer v0.0.0-20250819170608-69c2550f448e // indirect
git.max-richter.dev/max/marka/template v0.0.0-20250817132016-6db87db32567 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
go.yaml.in/yaml/v4 v4.0.0-rc.1 // indirect
golang.org/x/text v0.14.0 // indirect
)

View File

@@ -1,5 +1,5 @@
git.max-richter.dev/max/marka/parser v0.0.0-20250819170608-69c2550f448e h1:enZufetD3UoIVTnTNTQSFlr1Ir0jG7wObUAxb6+xwWg= git.max-richter.dev/max/marka/parser v0.0.0-20251003194139-ab81c980b590 h1:4C3b/KHD7+ru7nunpYIY6snVw+RI1QeVk9XcbzmdVY0=
git.max-richter.dev/max/marka/parser v0.0.0-20250819170608-69c2550f448e/go.mod h1:xQK6tsgr9BOoeFw8JxjBwDkVENlOqapmcRkYyf/L+SQ= git.max-richter.dev/max/marka/parser v0.0.0-20251003194139-ab81c980b590/go.mod h1:ykBvG4AW+fNFila0ZO2TlBqsCACYKb0AJaHsAopyRVI=
git.max-richter.dev/max/marka/registry v0.0.0-20250817132016-6db87db32567 h1:oe7Xb8dE43S8mRla5hfEqagMnvhvEVHsvRlzl2v540w= git.max-richter.dev/max/marka/registry v0.0.0-20250817132016-6db87db32567 h1:oe7Xb8dE43S8mRla5hfEqagMnvhvEVHsvRlzl2v540w=
git.max-richter.dev/max/marka/registry v0.0.0-20250817132016-6db87db32567/go.mod h1:qGWl42P8mgEktfor/IjQp0aS9SqmpeIlhSuVTlUOXLQ= git.max-richter.dev/max/marka/registry v0.0.0-20250817132016-6db87db32567/go.mod h1:qGWl42P8mgEktfor/IjQp0aS9SqmpeIlhSuVTlUOXLQ=
git.max-richter.dev/max/marka/renderer v0.0.0-20250819170608-69c2550f448e h1:9Eg81l8YMTXWZC3xlZ5L/NJRuK26bksrVtEHyCTV4sM= git.max-richter.dev/max/marka/renderer v0.0.0-20250819170608-69c2550f448e h1:9Eg81l8YMTXWZC3xlZ5L/NJRuK26bksrVtEHyCTV4sM=

View File

@@ -6,6 +6,8 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"time" "time"
"git.max-richter.dev/max/marka/parser"
) )
type LocalFsAdapter struct { type LocalFsAdapter struct {
@@ -32,11 +34,24 @@ func (l LocalFsAdapter) readDir(path string, root string) (FsResponse, error) {
entryType = contentTypeFor(e.Name()) entryType = contentTypeFor(e.Name())
} }
var content any
if !e.IsDir() && entryType == "application/markdown" {
entryPath := filepath.Join(path, e.Name())
fileContent, err := os.ReadFile(entryPath)
if err == nil {
parsedContent, err := parser.ParseFile(string(fileContent))
if err == nil {
content = parsedContent
}
}
}
out = append(out, FsDirEntry{ out = append(out, FsDirEntry{
Name: e.Name(), Name: e.Name(),
Type: entryType, Type: entryType,
IsDir: e.IsDir(), IsDir: e.IsDir(),
ModTime: info.ModTime(), ModTime: info.ModTime(),
Content: content,
}) })
} }

View File

@@ -20,6 +20,7 @@ type FsDirEntry struct {
Type string `json:"type"` Type string `json:"type"`
IsDir bool `json:"isDir,omitempty"` IsDir bool `json:"isDir,omitempty"`
ModTime time.Time `json:"modTime"` ModTime time.Time `json:"modTime"`
Content any `json:"content,omitempty"`
} }
type FsDir struct { type FsDir struct {