diff --git a/docs/content.md b/docs/content.md index 89320ae..0ec5aec 100644 --- a/docs/content.md +++ b/docs/content.md @@ -27,11 +27,31 @@ content/ │ │ └── john-doe.svg │ ├── john-doe.md │ └── jane-smith.md +├── data/ # Site data files exposed to templates +│ └── company.yaml ├── config.yaml # Site-wide settings (see docs/configuration.md) ├── navigation.yaml # Menu definitions └── standalone-page.md # Standalone page (not in any collection) ``` +## Site Data + +Put YAML files in `content/data/` to expose structured site data to templates. Each `.yaml` or `.yml` file becomes one key in the `$data` template variable using the file name without the extension. + +For example, `content/data/company.yaml`: + +```yaml +name: Acme +links: + - /about/ +``` + +is available in templates as: + +```php + +``` + ## Collections First-level directories under `content/` are **collections** (e.g., `blog/`, `docs/`). diff --git a/docs/templates.md b/docs/templates.md index 6f3c8ea..bc0d0f8 100644 --- a/docs/templates.md +++ b/docs/templates.md @@ -111,6 +111,7 @@ All built-in page templates receive these additional variables: | `$uiLanguages` | `list` | Available UI languages exposed by the site | | `$uiCatalogs` | `array>` | Theme UI catalogs for client-side switching | | `$ui` | `YiiPress\I18n\UiText` | Injected localized UI-text helper for bundled theme labels | +| `$data` | `array` | Site data loaded from `content/data/*.yaml` | | `$h` | `Closure(string, int, ?string, bool): string` | Injected alias for `htmlspecialchars()` | | `$t` | `Closure(string, array): string` | Injected shortcut for `$ui->get()` in templates | @@ -119,6 +120,7 @@ Example: ```php