页面或 collection scope 的 source 是一个四字段选择合同:
| 文件 | 含义 | 是否必需 |
|---|---|---|
<name> | /content/<type>/ 下的 path | 是 |
<name>.sort | sort expression | 否 |
<name>.limit | 结果最大数量 | 否 |
<name>.filter | 每行一条 filter condition | 否 |
例如 pages/topic/sources/related 是 topic 页面 scope 中名为 related 的 source。
filter 行为
一条 filter line 是 field/value condition。多行之间为 AND;同一行的逗号分隔值之间为 OR。当前匹配精确并且区分大小写;对象没有对应 field 时不匹配。
tags=AFS,Web Device
category=Research表示“tag 包含 AFS 或 Web Device,且 category 精确等于 Research”。先从未 filter 的 collection 开始,再加 sort、limit、最后 filter,这样空结果才容易诊断。
binding 行为
把 source 当作完整的顶层 layout prop 值,例如:
items=$source.related名称只在相关 page 或 collection scope 中解析,不是 site-wide variable。它不应插入任意 prose,也不能假定在任意 nested object 中解析。当前 source-binding check 在 scope 可知时能识别未声明的 $source.<name>;一些 shared named-layout 情形仍未被 init-time 完整覆盖。
无效 source path 会返回空结果,而不会读出 content root。空列表可能来自错误 path、filter/locale 不匹配,或确实没有对象;应检查生成页面,而不是把所有空结果当成同一种错误。
编写流程见 把内容绑定到页面。