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-zh/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
类型: 端点
路径: /api/ping
方法: GET
请求: none
响应: json
---
# main
`result` =
| ok | ping |
|----|------|
| True | pong |
*result*
@@ -0,0 +1,3 @@
### Marqdo
代码即文档,文档即可执行。
@@ -0,0 +1,18 @@
---
markup: occlusion
import:
文件: lib/文件.mq.md
组件: ext/web/网页/组件/索引.mq.md
---
## 节点
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Markdown leaf rows |
此叶子只负责footer/brand 的 Markdown 内容,父组件决定排列。修改文字只改相邻 content.md,
不添加 HTML 标签或内部分栏;出现第二种布局职责时再开子目录。
**body = 文件.读文本 路径="components/footer/brand/content.md"**
*> 组件.正文 文本=`body` 槽="footer-brand"*
@@ -0,0 +1,24 @@
---
markup: occlusion
import:
组件: ext/web/网页/组件/索引.mq.md
布局: ext/web/布局/索引.mq.md
brand: ./brand/index.mq.md
links: ./links/index.mq.md
---
## 节点
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Nested child rows |
本层只安排品牌内容与链接子树之间的关系,正文仍留在对应 Markdown 叶子中。
若子块仍含独立分栏,就继续沿对应目录的 index.mq.md 分解。
不要把渲染后的字符串放回值列,子节点在整个装配过程中保持结构。
**brand_nodes = > brand.节点**
**links_nodes = > links.节点**
**siblings = 组件.合并 甲=`brand_nodes` 乙=`links_nodes`**
**footer_columns = 布局.分栏 子节点=`siblings` 槽="footer"**
*> 组件.包裹 子节点=`footer_columns` 种类="footer" 槽="footer"*
@@ -0,0 +1,5 @@
### 社区
[关于项目](/about)
[返回首页](/)
@@ -0,0 +1,18 @@
---
markup: occlusion
import:
文件: lib/文件.mq.md
组件: ext/web/网页/组件/索引.mq.md
---
## 节点
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Markdown leaf rows |
此叶子只负责footer/links/community 的 Markdown 内容,父组件决定排列。修改文字只改相邻 content.md,
不添加 HTML 标签或内部分栏;出现第二种布局职责时再开子目录。
**body = 文件.读文本 路径="components/footer/links/community/content.md"**
*> 组件.正文 文本=`body` 槽="footer-links-community"*
@@ -0,0 +1,5 @@
### 文档
[开发手册](/about)
[服务状态](/api/ping)
@@ -0,0 +1,18 @@
---
markup: occlusion
import:
文件: lib/文件.mq.md
组件: ext/web/网页/组件/索引.mq.md
---
## 节点
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Markdown leaf rows |
此叶子只负责footer/links/docs 的 Markdown 内容,父组件决定排列。修改文字只改相邻 content.md,
不添加 HTML 标签或内部分栏;出现第二种布局职责时再开子目录。
**body = 文件.读文本 路径="components/footer/links/docs/content.md"**
*> 组件.正文 文本=`body` 槽="footer-links-docs"*
@@ -0,0 +1,23 @@
---
markup: occlusion
import:
组件: ext/web/网页/组件/索引.mq.md
布局: ext/web/布局/索引.mq.md
docs: ./docs/index.mq.md
community: ./community/index.mq.md
---
## 节点
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Nested child rows |
本层只安排文档链接与社区链接之间的关系,正文仍留在对应 Markdown 叶子中。
若子块仍含独立分栏,就继续沿对应目录的 index.mq.md 分解。
不要把渲染后的字符串放回值列,子节点在整个装配过程中保持结构。
**docs_nodes = > docs.节点**
**community_nodes = > community.节点**
**siblings = 组件.合并 甲=`docs_nodes` 乙=`community_nodes`**
*> 布局.分栏 子节点=`siblings` 槽="footer-links"*
@@ -0,0 +1,26 @@
---
markup: occlusion
import:
组件: ext/web/网页/组件/索引.mq.md
布局: ext/web/布局/索引.mq.md
nav: ./nav/index.mq.md
content: ./main/index.mq.md
footer: ./footer/index.mq.md
---
## 节点
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Nested child rows |
本层只安排导航、主体、页脚之间的关系,正文仍留在对应 Markdown 叶子中。
若子块仍含独立分栏,就继续沿对应目录的 index.mq.md 分解。
不要把渲染后的字符串放回值列,子节点在整个装配过程中保持结构。
**nav_nodes = > nav.节点**
**content_nodes = > content.节点**
**footer_nodes = > footer.节点**
**upper_regions = 组件.合并 甲=`nav_nodes` 乙=`content_nodes`**
**home_regions = 组件.合并 甲=`upper_regions` 乙=`footer_nodes`**
*> 布局.纵排 子节点=`home_regions` 槽="home"*
@@ -0,0 +1,3 @@
# 可执行文档站点
先拆布局,再写内容。**叶子只负责 Markdown。**
@@ -0,0 +1,18 @@
---
markup: occlusion
import:
文件: lib/文件.mq.md
组件: ext/web/网页/组件/索引.mq.md
---
## 节点
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Markdown leaf rows |
此叶子只负责main 的 Markdown 内容,父组件决定排列。修改文字只改相邻 content.md,
不添加 HTML 标签或内部分栏;出现第二种布局职责时再开子目录。
**body = 文件.读文本 路径="components/main/content.md"**
*> 组件.正文 文本=`body` 槽="main"*
@@ -0,0 +1 @@
[首页](/) · [关于](/about) · [状态](/api/ping)
@@ -0,0 +1,18 @@
---
markup: occlusion
import:
文件: lib/文件.mq.md
组件: ext/web/网页/组件/索引.mq.md
---
## 节点
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | Markdown leaf rows |
此叶子只负责nav 的 Markdown 内容,父组件决定排列。修改文字只改相邻 content.md,
不添加 HTML 标签或内部分栏;出现第二种布局职责时再开子目录。
**body = 文件.读文本 路径="components/nav/content.md"**
*> 组件.正文 文本=`body` 槽="nav"*
@@ -0,0 +1,16 @@
---
markup: occlusion
类型: 网页
视图: main
标题: Marqdo 布局实践
路由: /
import:
home: ./components/index.mq.md
---
# main
页面只选择布局根,具体拆分沿 components/index.mq.md 继续。
此主程序返回结构而不是 HTML;view 元数据让服务在启动时执行它。
*> home.节点*
@@ -0,0 +1,10 @@
---
markup: occlusion
类型: 网页
标题: 关于
路由: /about
---
# 关于
这是普通 Markdown Document,不执行布局函数。
@@ -0,0 +1,12 @@
---
markup: occlusion
import:
home: ./components/index.mq.md
网页: ext/web/网页.mq.md
---
# main
**nodes = > home.节点**
**html = 网页.渲染 节点=`nodes` 标题="Marqdo 布局实践"**
> 打印 内容=`html`
@@ -0,0 +1,12 @@
---
markup: occlusion
import:
网页: ext/web/网页.mq.md
---
# main
端口 `端口`=18081 可通过 --bind 覆盖。启动器不包含页面布局。
**监听端口 = 整数 值=`端口`**
> 网页.服务 根="." 主机="127.0.0.1" 端口=`监听端口`
+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`