Add taglist page
This commit is contained in:
parent
1625f36ba4
commit
5945f278ae
|
|
@ -36,6 +36,15 @@ module.exports = config => {
|
||||||
return [...collection.getFilteredByGlob('./src/posts/*.md')].reverse();
|
return [...collection.getFilteredByGlob('./src/posts/*.md')].reverse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Return all the tags used in a collection
|
||||||
|
config.addFilter("getAllTags", collection => {
|
||||||
|
let tagSet = new Set();
|
||||||
|
for(let item of collection) {
|
||||||
|
(item.data.tags || []).forEach(tag => tagSet.add(tag));
|
||||||
|
}
|
||||||
|
return Array.from(tagSet);
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
markdownTemplateEngine: 'njk',
|
markdownTemplateEngine: 'njk',
|
||||||
dataTemplateEngine: 'njk',
|
dataTemplateEngine: 'njk',
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,15 @@
|
||||||
"SkipLink": "Skip to content",
|
"SkipLink": "Skip to content",
|
||||||
"ToggleTheme": "Toggle theme",
|
"ToggleTheme": "Toggle theme",
|
||||||
"TopLink": "Back to top",
|
"TopLink": "Back to top",
|
||||||
|
"Listing": {
|
||||||
|
"Tags": {
|
||||||
|
"Title": "Tagged",
|
||||||
|
"More": {
|
||||||
|
"See": "See",
|
||||||
|
"All": "all tags"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"Footer": {
|
"Footer": {
|
||||||
"lastDeployment": "Dernier déploiement le",
|
"lastDeployment": "Dernier déploiement le",
|
||||||
"createdWith": "Built with"
|
"createdWith": "Built with"
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@
|
||||||
{
|
{
|
||||||
"text": "About",
|
"text": "About",
|
||||||
"url": "/about/"
|
"url": "/about/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "Blog",
|
||||||
|
"url": "/blog/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "Demo",
|
||||||
|
"url": "/tags/demo/"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
{% if tags %}
|
{% if tags %}
|
||||||
{% for tag in tags %}
|
{% for tag in tags %}
|
||||||
<li>
|
<li>
|
||||||
<a href="/tag/{{ tag | slug }}/">{{ tag | title }}</a>
|
<a href="/tags/{{ tag | slug }}/">{{ tag | title }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<section class="projects">
|
<section class="projects">
|
||||||
<ol reversed class="postlist">
|
<ol reversed class="postlist">
|
||||||
{%- asyncEach blog in collections.blog -%}
|
{%- asyncEach blog in postslist -%}
|
||||||
<li>
|
<li>
|
||||||
<h2><a href="{{ blog.url }}">{{ blog.data.title }}</a></h2>
|
<h2><a href="{{ blog.url }}">{{ blog.data.title }}</a></h2>
|
||||||
<ul class="list-inline">
|
<ul class="list-inline">
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
{%- if blog.data.tags -%}
|
{%- if blog.data.tags -%}
|
||||||
{%- for tag in blog.data.tags -%}
|
{%- for tag in blog.data.tags -%}
|
||||||
<li>
|
<li>
|
||||||
<a href="/tag/{{ tag | slug }}/">{{ tag | title }}</a>
|
<a href="/tags/{{ tag | slug }}/">{{ tag | title }}</a>
|
||||||
</li>
|
</li>
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
title: 'Blog'
|
title: 'Blog'
|
||||||
layout: 'list'
|
layout: 'list'
|
||||||
---
|
---
|
||||||
# Blog
|
# {{ title }}
|
||||||
|
|
||||||
The latest articles from around the studio, demonstrating our design
|
The latest articles from around the studio, demonstrating our design
|
||||||
thinking, strategy and expertise.
|
thinking, strategy and expertise.
|
||||||
|
|
||||||
|
{% set postslist = collections.blog %}
|
||||||
{% include "partials/post-list.html" %}
|
{% include "partials/post-list.html" %}
|
||||||
|
|
@ -7,4 +7,5 @@ metaDesc: 'A made up agency site that you build if you take Learn Eleventy From
|
||||||
layout: 'home'
|
layout: 'home'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
{% set postslist = collections.blog %}
|
||||||
{% include "partials/post-list.html" %}
|
{% include "partials/post-list.html" %}
|
||||||
13
src/tags-list.md
Normal file
13
src/tags-list.md
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
title: Tags
|
||||||
|
permalink: /tags/
|
||||||
|
layout: list
|
||||||
|
---
|
||||||
|
<h1 class="full-bleed">{{ title }}</h1>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{% for tag in collections.all | getAllTags %}
|
||||||
|
{% set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
|
||||||
|
<li><a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
36
src/tags.md
36
src/tags.md
|
|
@ -1,35 +1,17 @@
|
||||||
---
|
---
|
||||||
title: 'Tag Archive'
|
eleventyComputed:
|
||||||
layout: 'list'
|
title: "{{ Term.Site.Listing.Tags.Title }} “{{ tag }}”"
|
||||||
|
permalink: '/tags/{{ tag | slug }}/'
|
||||||
pagination:
|
pagination:
|
||||||
data: collections
|
data: collections
|
||||||
size: 1
|
size: 1
|
||||||
alias: tag
|
alias: tag
|
||||||
permalink: '/tag/{{ tag | slug }}/'
|
layout: 'list'
|
||||||
---
|
---
|
||||||
|
|
||||||
<h1>Tagged “{{ tag }}”</h1>
|
<h1 class="full-bleed">{{ Term.Site.Listing.Tags.Title }} “{{ tag }}”</h1>
|
||||||
|
|
||||||
<section class="projects">
|
{% set postslist = collections[ tag ] %}
|
||||||
<ol reversed class="postlist">
|
{% include "partials/post-list.html" %}
|
||||||
{% set taglist = collections[ tag ] %}
|
|
||||||
{% for blog in taglist | reverse %}
|
<p>{{ Term.Site.Listing.Tags.More.See }} <a href="/tags/">{{ Term.Site.Listing.Tags.More.All }}</a>.</p>
|
||||||
<li>
|
|
||||||
<h2><a href="{{ blog.url }}">{{ blog.data.title }}</a></h2>
|
|
||||||
<ul class="list-inline">
|
|
||||||
<li><time datetime="{{ blog.date | getDatetime }}">{{ blog.date | toFullDate }}</time></li>
|
|
||||||
{%- if blog.data.tags -%}
|
|
||||||
{%- for tag in blog.data.tags -%}
|
|
||||||
<li>
|
|
||||||
<a href="/tag/{{ tag | slug }}/">{{ tag | title }}</a>
|
|
||||||
</li>
|
|
||||||
{%- endfor -%}
|
|
||||||
{%- endif -%}
|
|
||||||
</ul>
|
|
||||||
{%- if blog.data.leading -%}
|
|
||||||
<p>{{ blog.data.leading }}</p>
|
|
||||||
{%- endif -%}
|
|
||||||
</li>
|
|
||||||
{%- endfor -%}
|
|
||||||
</ol>
|
|
||||||
</section>
|
|
||||||
Loading…
Reference in a new issue