Make Web an executable handbook with recursive Markdown layouts

This commit is contained in:
cflmy committed 2026-11-08 21:50:01 +08:00
1 parent cc5277d2b5
commit 5080136d65
84 files changed
+3394 -957

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
# Layout decomposition reference
Read [the page](index.mq.md), then follow [components](components/index.mq.md) to
navigation, main and footer. Footer splits into brand and links; links splits
again into docs and community. Every terminal content.md is plain Markdown.
Parent .mq.md files only load/compose child rows and choose one relationship.
From the repository root, preview with:
```bash
marqdo run examples/web-layout-handbook/preview.mq.md
```
To serve, change into this directory, then run:
```bash
marqdo run serve.mq.md
```
Check /, /about and /api/ping. Geometry comes from the runtime's row/column
containers. No authored HTML or CSS is needed. view: main is evaluated once at
startup; restart after edits. Request-time interaction belongs in Endpoints.
@@ -0,0 +1,18 @@
---
markup: occlusion
type: endpoint
path: /api/ping
method: GET
request: none
response: json
---
# main
`result` =
| ok | ping |
|----|------|
| True | pong |
*result*
@@ -0,0 +1,3 @@
### Marqdo
Code is documentation. Documents are executable.
@@ -0,0 +1,19 @@
---
markup: occlusion
import:
fs: lib/fs.mq.md
component: ext/web/component/index.mq.md
---
## nodes
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Markdown leaf rows |
This leaf owns only the footer/brand Markdown content; its parent owns placement.
Edit adjacent content.md to change prose. Add a child directory when a second
layout responsibility appears instead of introducing HTML into the content.
**body = fs.read_text path="components/footer/brand/content.md"**
*> component.markdown text=`body` slot="footer-brand"*
@@ -0,0 +1,24 @@
---
markup: occlusion
import:
component: ext/web/component/index.mq.md
layout: ext/web/layout/index.mq.md
brand: ./brand/index.mq.md
links: ./links/index.mq.md
---
## nodes
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Nested child rows |
This parent arranges brand content and the link-region subtree. Content stays
in their Markdown leaves; this file owns their one placement relationship. Continue into each child index when another independent layout
remains. Preserve node lists rather than rendering children into HTML strings.
**brand_nodes = > brand.nodes**
**links_nodes = > links.nodes**
**siblings = component.merge a=`brand_nodes` b=`links_nodes`**
**footer_columns = layout.columns children=`siblings` slot="footer"**
*> component.wrap children=`footer_columns` kind="footer" slot="footer"*
@@ -0,0 +1,5 @@
### Community
[About the project](/about)
[Return home](/)
@@ -0,0 +1,19 @@
---
markup: occlusion
import:
fs: lib/fs.mq.md
component: ext/web/component/index.mq.md
---
## nodes
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Markdown leaf rows |
This leaf owns only the footer/links/community Markdown content; its parent owns placement.
Edit adjacent content.md to change prose. Add a child directory when a second
layout responsibility appears instead of introducing HTML into the content.
**body = fs.read_text path="components/footer/links/community/content.md"**
*> component.markdown text=`body` slot="footer-links-community"*
@@ -0,0 +1,5 @@
### Documentation
[Handbook](/about)
[Service status](/api/ping)
@@ -0,0 +1,19 @@
---
markup: occlusion
import:
fs: lib/fs.mq.md
component: ext/web/component/index.mq.md
---
## nodes
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Markdown leaf rows |
This leaf owns only the footer/links/docs Markdown content; its parent owns placement.
Edit adjacent content.md to change prose. Add a child directory when a second
layout responsibility appears instead of introducing HTML into the content.
**body = fs.read_text path="components/footer/links/docs/content.md"**
*> component.markdown text=`body` slot="footer-links-docs"*
@@ -0,0 +1,23 @@
---
markup: occlusion
import:
component: ext/web/component/index.mq.md
layout: ext/web/layout/index.mq.md
docs: ./docs/index.mq.md
community: ./community/index.mq.md
---
## nodes
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Nested child rows |
This parent arranges documentation links and community links. Content stays
in their Markdown leaves; this file owns their one placement relationship. Continue into each child index when another independent layout
remains. Preserve node lists rather than rendering children into HTML strings.
**docs_nodes = > docs.nodes**
**community_nodes = > community.nodes**
**siblings = component.merge a=`docs_nodes` b=`community_nodes`**
*> layout.columns children=`siblings` slot="footer-links"*
@@ -0,0 +1,26 @@
---
markup: occlusion
import:
component: ext/web/component/index.mq.md
layout: ext/web/layout/index.mq.md
nav: ./nav/index.mq.md
content: ./main/index.mq.md
footer: ./footer/index.mq.md
---
## nodes
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Nested child rows |
This parent arranges navigation, main content and footer. Content stays
in their Markdown leaves; this file owns their one placement relationship. Continue into each child index when another independent layout
remains. Preserve node lists rather than rendering children into HTML strings.
**nav_nodes = > nav.nodes**
**content_nodes = > content.nodes**
**footer_nodes = > footer.nodes**
**upper_regions = component.merge a=`nav_nodes` b=`content_nodes`**
**home_regions = component.merge a=`upper_regions` b=`footer_nodes`**
*> layout.stack children=`home_regions` slot="home"*
@@ -0,0 +1,3 @@
# Executable documents
Split the layout before writing content. **Leaves own Markdown only.**
@@ -0,0 +1,19 @@
---
markup: occlusion
import:
fs: lib/fs.mq.md
component: ext/web/component/index.mq.md
---
## nodes
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Markdown leaf rows |
This leaf owns only the main Markdown content; its parent owns placement.
Edit adjacent content.md to change prose. Add a child directory when a second
layout responsibility appears instead of introducing HTML into the content.
**body = fs.read_text path="components/main/content.md"**
*> component.markdown text=`body` slot="main"*
@@ -0,0 +1 @@
[Home](/) · [About](/about) · [Status](/api/ping)
@@ -0,0 +1,19 @@
---
markup: occlusion
import:
fs: lib/fs.mq.md
component: ext/web/component/index.mq.md
---
## nodes
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Markdown leaf rows |
This leaf owns only the nav Markdown content; its parent owns placement.
Edit adjacent content.md to change prose. Add a child directory when a second
layout responsibility appears instead of introducing HTML into the content.
**body = fs.read_text path="components/nav/content.md"**
*> component.markdown text=`body` slot="nav"*
+16
View File
@@ -0,0 +1,16 @@
---
markup: occlusion
type: web
view: main
title: Marqdo layout handbook
route: /
import:
home: ./components/index.mq.md
---
# main
The page selects the layout root; follow components/index.mq.md for decomposition.
This main returns rows rather than HTML; view metadata opts into startup assembly.
*> home.nodes*
@@ -0,0 +1,10 @@
---
markup: occlusion
type: web
title: About
route: /about
---
# About
An ordinary Markdown Document keeps its original rendering path.
@@ -0,0 +1,12 @@
---
markup: occlusion
import:
home: ./components/index.mq.md
web: ext/web/web.mq.md
---
# main
**nodes = > home.nodes**
**html = web.render nodes=`nodes` title="Marqdo layout handbook"**
> print text=`html`
+12
View File
@@ -0,0 +1,12 @@
---
markup: occlusion
import:
web: ext/web/web.mq.md
---
# main
The `port`=18081 may be overridden with --bind. This launcher owns no layout.
**listen_port = int value=`port`**
> web.serve root="." host="127.0.0.1" port=`listen_port`