From 3af6d9131f6dfc138856d718ec96626344095ec8 Mon Sep 17 00:00:00 2001 From: Jieiku Date: Mon, 22 May 2023 23:24:44 -0700 Subject: Optimizations and Fixes --- content/posts/_index.md | 1 - 1 file changed, 1 deletion(-) (limited to 'content/posts/_index.md') diff --git a/content/posts/_index.md b/content/posts/_index.md index e381261..c700dc5 100644 --- a/content/posts/_index.md +++ b/content/posts/_index.md @@ -1,4 +1,3 @@ +++ -title = "posts" template = "posts.html" +++ -- cgit v1.3.1 From 65f135a6a2f7be105bfe9ce95796b2314627b20d Mon Sep 17 00:00:00 2001 From: Jieiku Date: Tue, 18 Jul 2023 13:23:00 -0700 Subject: Add Examples for Sections and Transparent Sections --- config.toml | 2 +- content/archive/_index.fr.md | 3 ++ content/archive/_index.md | 3 ++ content/blog/_index.fr.md | 5 +++ content/blog/_index.md | 5 +++ content/blog/blog-section.fr.md | 29 +++++++++++++++++ content/blog/blog-section.md | 29 +++++++++++++++++ content/posts/_index.fr.md | 3 +- content/posts/_index.md | 3 +- content/posts/posts-section.fr.md | 20 ++++++++++++ content/posts/posts-section.md | 20 ++++++++++++ templates/archive.html | 68 +++++++++++++++++++++++++++++++++++++++ templates/posts.html | 68 --------------------------------------- 13 files changed, 187 insertions(+), 71 deletions(-) create mode 100644 content/archive/_index.fr.md create mode 100644 content/archive/_index.md create mode 100644 content/blog/_index.fr.md create mode 100644 content/blog/_index.md create mode 100644 content/blog/blog-section.fr.md create mode 100644 content/blog/blog-section.md create mode 100644 content/posts/posts-section.fr.md create mode 100644 content/posts/posts-section.md create mode 100644 templates/archive.html delete mode 100644 templates/posts.html (limited to 'content/posts/_index.md') diff --git a/config.toml b/config.toml index 8dd0442..d5ab0c3 100644 --- a/config.toml +++ b/config.toml @@ -103,7 +103,7 @@ flag.fr = "🇫🇷" menu = [ {url = "about", name = "About", slash = true, blank = false}, - {url = "posts", name = "Posts", slash = true, blank = false}, + {url = "archive", name = "Posts", slash = true, blank = false}, {url = "categories", name = "Categories", slash = true, blank = false}, {url = "tags", name = "Tags", slash = true, blank = false}, ] diff --git a/content/archive/_index.fr.md b/content/archive/_index.fr.md new file mode 100644 index 0000000..b1a35cf --- /dev/null +++ b/content/archive/_index.fr.md @@ -0,0 +1,3 @@ ++++ +template = "archive.html" ++++ diff --git a/content/archive/_index.md b/content/archive/_index.md new file mode 100644 index 0000000..b1a35cf --- /dev/null +++ b/content/archive/_index.md @@ -0,0 +1,3 @@ ++++ +template = "archive.html" ++++ diff --git a/content/blog/_index.fr.md b/content/blog/_index.fr.md new file mode 100644 index 0000000..0b72ce0 --- /dev/null +++ b/content/blog/_index.fr.md @@ -0,0 +1,5 @@ ++++ +template = "index.html" +paginate_by = 3 +sort_by = "date" ++++ diff --git a/content/blog/_index.md b/content/blog/_index.md new file mode 100644 index 0000000..0b72ce0 --- /dev/null +++ b/content/blog/_index.md @@ -0,0 +1,5 @@ ++++ +template = "index.html" +paginate_by = 3 +sort_by = "date" ++++ diff --git a/content/blog/blog-section.fr.md b/content/blog/blog-section.fr.md new file mode 100644 index 0000000..6c1fe97 --- /dev/null +++ b/content/blog/blog-section.fr.md @@ -0,0 +1,29 @@ ++++ +title = "Blog Section" +date = 2021-05-04 +draft = false + +[taxonomies] +categories = ["Features"] +tags = ["config"] ++++ + +Vous pouvez placer votre contenu dans content/blog/ au lieu de content/ cela fera des URL de publication example.com/blog/post-title + +Dans le répertoire du blog, vous verrez le _index.md: + +```md ++++ +template = "index.html" +paginate_by = 3 +sort_by = "date" ++++ +``` + +Au lieu de index.html, vous pouvez également spécifier archive.html, les deux modèles prennent en charge les sections: + +```md ++++ +template = "archive.html" ++++ +``` diff --git a/content/blog/blog-section.md b/content/blog/blog-section.md new file mode 100644 index 0000000..71bb0f5 --- /dev/null +++ b/content/blog/blog-section.md @@ -0,0 +1,29 @@ ++++ +title = "Blog Section" +date = 2021-05-04 +draft = false + +[taxonomies] +categories = ["Features"] +tags = ["config"] ++++ + +You can place your content in content/blog/ instead of content/ this will make post urls example.com/blog/post-title + +In the blog directory you will see the _index.md: + +```md ++++ +template = "index.html" +paginate_by = 3 +sort_by = "date" ++++ +``` + +Instead of index.html you can also specify archive.html, both templates support sections: + +```md ++++ +template = "archive.html" ++++ +``` diff --git a/content/posts/_index.fr.md b/content/posts/_index.fr.md index c700dc5..6b70666 100644 --- a/content/posts/_index.fr.md +++ b/content/posts/_index.fr.md @@ -1,3 +1,4 @@ +++ -template = "posts.html" +transparent = true +redirect_to = "/" +++ diff --git a/content/posts/_index.md b/content/posts/_index.md index c700dc5..6b70666 100644 --- a/content/posts/_index.md +++ b/content/posts/_index.md @@ -1,3 +1,4 @@ +++ -template = "posts.html" +transparent = true +redirect_to = "/" +++ diff --git a/content/posts/posts-section.fr.md b/content/posts/posts-section.fr.md new file mode 100644 index 0000000..63e71af --- /dev/null +++ b/content/posts/posts-section.fr.md @@ -0,0 +1,20 @@ ++++ +title = "Posts Transparent Section" +date = 2021-05-04 +draft = false + +[taxonomies] +categories = ["Features"] +tags = ["config"] ++++ + +Vous pouvez placer votre contenu dans content/posts/ au lieu de content/ cela fera des URL de publication example.com/posts/post-title + +Dans le répertoire des articles, vous verrez le _index.md : + +```md ++++ +transparent = true +redirect_to = "/" ++++ +``` diff --git a/content/posts/posts-section.md b/content/posts/posts-section.md new file mode 100644 index 0000000..c90ec99 --- /dev/null +++ b/content/posts/posts-section.md @@ -0,0 +1,20 @@ ++++ +title = "Posts Transparent Section" +date = 2021-05-04 +draft = false + +[taxonomies] +categories = ["Features"] +tags = ["config"] ++++ + +You can place your content in content/posts/ instead of content/ this will make post urls example.com/posts/post-title + +In the posts directory you will see the _index.md: + +```md ++++ +transparent = true +redirect_to = "/" ++++ +``` diff --git a/templates/archive.html b/templates/archive.html new file mode 100644 index 0000000..fdbb5e8 --- /dev/null +++ b/templates/archive.html @@ -0,0 +1,68 @@ +{# +This Page Shows the Posts Grouped by Year: example.com/archive/ +This Template can also be used as the rendering template for Sections, eg: example.com/blog/ example.com/software/ +#} + +{% extends "base.html" %} + +{%- block seo %} + {{- super() }} + {%- set title = "Archive" %} + + {%- if config.title %} + {%- set title_addition = title_separator ~ config.title %} + {%- else %} + {%- set title_addition = "" %} + {%- endif %} + + {%- set description = config.description %} + + {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} +{%- endblock seo %} + +{%- block content %} + {#- The following line is checking if the template is being used for the archive page or a section #} + {%- if current_path is matching("^(/[[:alpha:]][[:alpha:]])?/archive/$") %} + {%- set sec = "" %} + {%- else %} + {%- set langpath = "/" %} + {%- if lang != config.default_language %} + {%- set langpath = "/" ~ lang ~ "/" %} + {%- endif %} + + {%- set sec = current_path | trim_start_matches(pat=langpath) | split(pat="/page/") | slice(end=1) | join(sep="") | trim_end_matches(pat="/") %} + {%- set sec = sec ~ "/" %} + {%- endif %} + + {%- if lang == config.default_language %} + {%- set section_item = get_section(path=sec ~ "_index.md") %} + {%- else %} + {%- set section_item = get_section(path=sec ~ "_index." ~ lang ~ ".md") %} + {%- endif %} + {%- if sec != "" %} + {#- the section always overrides the config -#} + {%- if section_item.extra and 'hide_section_dates' in section_item.extra -%} + {%- set hide_section_dates = section_item.extra.hide_section_dates -%} + {%- elif config.extra.hide_section_dates -%} + {%- set hide_section_dates = true -%} + {%- endif -%} + {%- endif %} +
{{ post.title }}{%- if not hide_section_dates %} - {%- endif %}
+ {%- endfor %} + {%- endfor %} +{{ post.title }}{%- if not hide_section_dates %} - {%- endif %}
- {%- endfor %} - {%- endfor %} -