Make Web an executable handbook with recursive Markdown layouts
This commit is contained in:
1 parent
cc5277d2b5
commit
5080136d65
84 files changed
+3394
-957
No files matched your search
@@ -2,6 +2,7 @@ package render
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -11,7 +12,20 @@ import (
|
||||
)
|
||||
|
||||
func TestAnlianPostsResolve(t *testing.T) {
|
||||
url := "sqlite:/home/cflmy/work/marqdo/examples/anlian-mq/data/anlian-mq.db"
|
||||
url := "sqlite:" + filepath.Join(t.TempDir(), "anlian.db")
|
||||
fields := []any{
|
||||
map[string]any{"name": "title", "type": "text", "nullable": false},
|
||||
map[string]any{"name": "summary", "type": "text"},
|
||||
map[string]any{"name": "board", "type": "text"},
|
||||
map[string]any{"name": "slug", "type": "text"},
|
||||
}
|
||||
if _, err := db.Init(url, "posts", fields); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rows := []any{map[string]any{"title": "欢迎", "summary": "Portable test fixture", "board": "demo", "slug": "welcome"}}
|
||||
if _, err := db.Insert(url, "posts", rows); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
card := map[string]any{
|
||||
"属性": []any{"title", "body", "meta", "href"},
|
||||
"值": []any{"posts.title", "posts.summary", "posts.board", "posts.slug"},
|
||||
|
||||
@@ -1272,7 +1272,6 @@ func resolveFormData(page map[string]any, dbURL string) map[string]any {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
func pushIntro(buf *strings.Builder, intro string) {
|
||||
pushIntroAndForm(buf, intro, nil)
|
||||
}
|
||||
@@ -1364,6 +1363,12 @@ func renderFragment(page map[string]any, dbURL, slot string) string {
|
||||
|
||||
// RenderPage builds full-page HTML (or a part fragment when partID is set).
|
||||
func RenderPage(page map[string]any, dbURL string, partID string) string {
|
||||
// Explicit View Documents already own their structure and document shell.
|
||||
if partID == "" && page != nil {
|
||||
if html, ok := page["artifact_html"].(string); ok {
|
||||
return html
|
||||
}
|
||||
}
|
||||
if page == nil {
|
||||
page = map[string]any{}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user