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

misc: Rename site.data to site.extra #74

Merged
merged 1 commit into from
Oct 24, 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
2 changes: 1 addition & 1 deletion .github/marmite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ menu:
- ['Create a blog', "https://github.com/rochacbruno/blog/"]
- ['Github', 'https://github.com/rochacbruno/marmite/']
- ['Tags', 'tags.html']
data:
extra:
comments:
title: Comments
source: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ url: https://www.myblog.com

# menu:
# - ["Title", "link.html"]
# data: Custom key:pair values to be exposed to template context.
# extra: Custom key:pair values to be exposed to template context.
```

### Content types
Expand Down
7 changes: 4 additions & 3 deletions example/content/customizing-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ site:
url: str
tagline: str
pagination: int
extra: {k, v}
...the keys on site configuration.
menu: [[name, link]]
```
Expand Down Expand Up @@ -89,17 +90,17 @@ On templates use the `url_for` function to refer to urls.

## Extra data

On site config `marmite.yaml` there is an arbitrary field `data` that can be accessed
On site config `marmite.yaml` there is an arbitrary field `extra` that can be accessed
on any template.

```yaml
data:
extra:
myname: Bruno
```
Then on an template.

```html
{{site.data.myname}}
{{site.extra.myname}}
```

On each individual post there is a `extra` arbitrary field, so on `list.html` and
Expand Down
8 changes: 4 additions & 4 deletions example/content/enabling-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Now go to https://giscus.app/ and find the **configuration** section.
Copy the `<script ... /script>` that was presented and put it in your `marmite.yaml`

```yaml
data:
extra:
comments:
title: Comments
source: |
Expand All @@ -69,7 +69,7 @@ data:
The process will be very similar, you just need to grab the required `script` and tags.

```yaml
data:
extra:
comments:
title: Comments
source: |
Expand All @@ -83,7 +83,7 @@ Add `templates/comments.html` to your project.

```html
<article>
<header>{{site.data.comments.title | default(value="Comments") }}</header>
{{site.data.comments.source}}
<header>{{site.extra.comments.title | default(value="Comments") }}</header>
{{site.extra.comments.source}}
</article>
```
4 changes: 2 additions & 2 deletions example/marmite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ menu:


# extra data for template customization
# data:
# extra:
# foo: bar

# Example, to enable comments:
# Go to: https://giscus.app/ and generate your config and replace below.
# If you prefer to use a different commenting system just replace accordingly
# disqus, utterance.s and others works.
# data:
# extra:
# comments:
# title: Comentários
# source: |
Expand Down
4 changes: 2 additions & 2 deletions example/templates/comments.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<article>
<header>{{site.data.comments.title | default(value="Comments") }}</header>
{{site.data.comments.source}}
<header>{{site.extra.comments.title | default(value="Comments") }}</header>
{{site.extra.comments.source}}
</article>
2 changes: 1 addition & 1 deletion example/templates/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{% endif %}
</article>

{% if site.data.comments.source is defined and content.date %}
{% if site.extra.comments.source is defined and content.date %}
{%include "comments.html"%}
{% endif %}

Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ pub struct Marmite<'a> {
#[serde(default = "default_menu")]
pub menu: Option<Vec<(String, String)>>,

#[serde(default = "default_data")]
pub data: Option<HashMap<String, Value>>,
#[serde(default = "default_extra")]
pub extra: Option<HashMap<String, Value>>,
}

fn default_name() -> &'static str {
Expand Down Expand Up @@ -125,6 +125,6 @@ fn default_menu() -> Option<Vec<(String, String)>> {
.into()
}

fn default_data() -> Option<HashMap<String, Value>> {
fn default_extra() -> Option<HashMap<String, Value>> {
None
}