Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Improve data explanation, more links #97

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions docs/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ data:
---
## Data Files

Cobalt supports loading [yaml](http://yaml.org), [json](http://json.org), and
[toml](https://github.com/toml-lang/toml.html) from [`_data`](/docs/directory)
and making it available as [`site.data.<DIR>.<FILE>`](/docs/variables).
Cobalt reads data from any [yaml](http://yaml.org), [json](http://json.org), and
[toml](https://github.com/toml-lang/toml.html) files in the [`_data` directory](/docs/directory)
and merges them into the [`site.data`](/docs/variables) variable, making
them available as `site.data.<DIR>.<FILE>`.

### Example

Expand All @@ -17,7 +18,7 @@ In `_data/animals/dogs.yml`:
- name: Corgi
- name: Malamute
```
which can be accessed via `site.data.animals.dogs`.
which liquid templates can access via `site.data.animals.dogs`.

You can now render the list in a template:
```html
Expand Down
2 changes: 1 addition & 1 deletion docs/directory.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ File / Directory | Description
`_cobalt.yml` | Site-wide [configuration](/docs/config) file
`_layouts` | [Templates](/docs/layouts) that wrap pages. The layout is chosen in the [frontmatter](/docs/pages)
`_includes` | Liquid snippets of content to be shared among [layouts](/docs/layouts) or pages.
`_data` | Data files that will be loaded as part of the `{%raw%}{{ site.data }}{%endraw%}` variable.
`_data` | [Data files](/docs/data) in this directory are loaded as part of the `{%raw%}{{ site.data }}{%endraw%}` [variable](/docs/variables).
`_sass` | Sass snippets that can be imported into your `.scss` files.
`_site` | The output directory of cobalt. Can be modified in [`_cobalt.yml`](/docs/config).
`_defaults` | `cobalt new` initializes files from here based on the collection name.
Expand Down
2 changes: 1 addition & 1 deletion docs/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Variable | Format | Description
`site.title` | String | The title of the entire site, see [`_cobalt.yml`](/docs/config).
`site.description` | String | The description of the entire site, see [`_cobalt.yml`](/docs/config).
`site.base_url` | String | The URL of your site, see [`_cobalt.yml`](/docs/config). This is helpful for making absolute URLs, particularly when run within [`cobalt serve`](/docs/usage).
`site.data` | Object | The merged result of [`_data`](/docs/directory) and [`site: data`](/docs/config).
`site.data` | Object | The merged result of [data files](/docs/data) in the [`_data`](/docs/directory) directory and [`site: data`](/docs/config) in `_cobalt.yml`.
`site.time` | DateTime | A `liquid_core::model::DateTime` representing the time of the website re-generation.

### Page Variables
Expand Down
Loading