Skip to content

Commit

Permalink
Merge pull request #97 from skierpage/patch-data-link
Browse files Browse the repository at this point in the history
docs: Improve data explanation, more links
  • Loading branch information
epage authored Jul 12, 2024
2 parents 0e480e9 + f4f7a17 commit dce0c77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
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

0 comments on commit dce0c77

Please sign in to comment.