Skip to content

Commit

Permalink
fix: add language
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Nov 21, 2024
1 parent a6852df commit 6d3af4a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions example/content/2024-10-20-content-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ menu:
- ["Projects", "projects.html"]
- ["Contact", "contact.html"]
- ["Github", "https://github.com/rochacbruno"]
extra:
colorscheme: gruvbox
fediverse_verification: https://mastodon.social/@me
```

Other options are available and can be viewed on [repository](https://github.com/rochacbruno/marmite/blob/main/example/marmite.yaml)
Expand Down
5 changes: 2 additions & 3 deletions example/marmite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ authors:
- ["Github", "https://github.com/karlamagueta"]

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

extra:
colorscheme_toggle: true
# colorscheme: gruvbox
# fediverse_verification: https://mastodon.social/@me

# Example, to enable comments:
# Go to: https://giscus.app/ and generate your config and replace below.
Expand Down
4 changes: 2 additions & 2 deletions example/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{language}}">
<head>
<meta charset="UTF-8">
<link rel="icon" type="image/x-icon" href="./static/favicon.ico">
Expand All @@ -18,7 +18,7 @@
<meta property="og:type" content="website">
<meta property="og:site_name" content="{{site.name}}">
{% if site.extra.fediverse_verification %}
<linl rel="me" href="{{site.extra.fediverse_verification}}">
<link rel="me" href="{{site.extra.fediverse_verification}}">
{% endif %}
{% endblock %}
{%- block head %}
Expand Down
7 changes: 5 additions & 2 deletions example/templates/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<article>
Back-links
<ul>
{% for item in content.back_links | sort(attribute="date") | reverse | slice(end=10) %}
{% for item in content.back_links | slice(end=10) %}
<li><a href="./{{item.slug }}.html">{{item.title}}</a></li>
{% endfor %}
</ul>
Expand All @@ -90,17 +90,20 @@
{% if content.tags %}
{# Only the first tag for now #}
{% set tag = content.tags[0] %}
{% set related_content = site_data.tag.map[tag] %}
{% if related_content | length > 1 %}
<article>
Related {{tag}} content
<ul>
{% for item in site_data.tag.map[tag] | sort(attribute="date") | reverse | slice(end=5) %}
{% for item in related_content | sort(attribute="date") | reverse | slice(end=5) %}
{% if item.slug == content.slug or item in content.back_links %}
{% continue %}
{% endif %}
<li><a href="./{{item.slug }}.html">{{item.title}}</a></li>
{% endfor %}
</ul>
</article>
{% endif %}
{% endif %}

{% if site.extra.comments.source is defined and content.date %}
Expand Down
6 changes: 6 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub struct Marmite {
pub url: String,
#[serde(default = "default_footer")]
pub footer: String,
#[serde(default = "default_language")]
pub language: String,
#[serde(default = "default_pagination")]
pub pagination: usize,
#[serde(default = "default_pages_title")]
Expand Down Expand Up @@ -190,3 +192,7 @@ fn default_menu() -> Option<Vec<(String, String)>> {
fn default_search_title() -> String {
"Search".to_string()
}

fn default_language() -> String {
"en".to_string()
}
1 change: 1 addition & 0 deletions src/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ fn render_templates(
global_context.insert("site_data", &site_data);
global_context.insert("site", &site_data.site);
global_context.insert("menu", &site_data.site.menu);
global_context.insert("language", &site_data.site.language);
debug!("Global Context site: {:?}", &site_data.site);

// Assuming every item on site_data.posts is a Content and has a stream field
Expand Down

0 comments on commit 6d3af4a

Please sign in to comment.