feat: add draft support
parent
d11ca2e133
commit
bef7af2d08
|
@ -70,19 +70,30 @@ module.exports = function(eleventyConfig) {
|
||||||
return Math.min.apply(null, numbers);
|
return Math.min.apply(null, numbers);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
eleventyConfig.addFilter("filterDraft", articles => {
|
||||||
|
return articles.filter(article => !article.data.draft);
|
||||||
|
});
|
||||||
|
|
||||||
// Return all the tags used in a collection
|
// Return all the tags used in a collection
|
||||||
eleventyConfig.addFilter("getAllTags", collection => {
|
eleventyConfig.addFilter("getAllTags", collection => {
|
||||||
let tagSet = new Set();
|
let tags = new Map();
|
||||||
for(let item of collection) {
|
for(let item of collection) {
|
||||||
(item.data.tags || []).forEach(tag => tagSet.add(tag));
|
if (item.data.draft) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
(item.data.tags || []).forEach(tag => {
|
||||||
|
let number = tags.get(tag) || 0;
|
||||||
|
tags.set(tag, ++number);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return Array.from(tagSet).sort((a, b) => {
|
let sortedTags = new Map([...tags.entries()].sort((a, b) => b[1] - a[1]));
|
||||||
return a.localeCompare(b, undefined, {sensitivity: 'base'});
|
return Array.from(sortedTags.keys());
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
eleventyConfig.addFilter("filterTagList", function filterTagList(tags) {
|
eleventyConfig.addFilter("filterTagList", function filterTagList(tags) {
|
||||||
return (tags || []).filter(tag => ["all", "nav", "article", "articles"].indexOf(tag) === -1);
|
return (tags || []).filter(tag => ["all", "nav", "article", "articles"].indexOf(tag) === -1);
|
||||||
|
// const filters = ["all", "nav", "article", "articles"];
|
||||||
|
// return new Map([...tags].filter(([k, _]) => filters.indexOf(k) === -1));
|
||||||
});
|
});
|
||||||
|
|
||||||
eleventyConfig.addFilter("readableAuthors", (authors) => {
|
eleventyConfig.addFilter("readableAuthors", (authors) => {
|
||||||
|
|
|
@ -21,10 +21,11 @@ templateClass: tmpl-post
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
{%- if collections.articles %}
|
{%- set articles = collections.articles | filterDraft %}
|
||||||
|
{%- if articles %}
|
||||||
{# these filters are locale-aware in 2.0.0-canary.14 #}
|
{# these filters are locale-aware in 2.0.0-canary.14 #}
|
||||||
{%- set previousArticle = collections.articles | getPreviousCollectionItem %}
|
{%- set previousArticle = articles | getPreviousCollectionItem %}
|
||||||
{%- set nextArticle = collections.articles | getNextCollectionItem %}
|
{%- set nextArticle = articles | getNextCollectionItem %}
|
||||||
{%- if nextArticle or previousArticle %}
|
{%- if nextArticle or previousArticle %}
|
||||||
<nav class="post-nav">
|
<nav class="post-nav">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -9,7 +9,7 @@ eleventyNavigation:
|
||||||
<nav>
|
<nav>
|
||||||
{% include "tagslist.njk" %}
|
{% include "tagslist.njk" %}
|
||||||
</nav>
|
</nav>
|
||||||
{% set articlesList = collections.articles %}
|
{% set articlesList = collections.articles | filterDraft %}
|
||||||
{% include "articlesList.njk" %}
|
{% include "articlesList.njk" %}
|
||||||
</div>
|
</div>
|
||||||
<aside class="right-side">
|
<aside class="right-side">
|
||||||
|
|
|
@ -8,6 +8,7 @@ tags:
|
||||||
- ACV
|
- ACV
|
||||||
authors:
|
authors:
|
||||||
- Margaux Escande
|
- Margaux Escande
|
||||||
|
draft: false
|
||||||
layout: article.njk
|
layout: article.njk
|
||||||
---
|
---
|
||||||
À ce jour, le numérique a plus d'impacts environnementaux que l'aviation civile et ses impacts continuent d'augmenter.
|
À ce jour, le numérique a plus d'impacts environnementaux que l'aviation civile et ses impacts continuent d'augmenter.
|
||||||
|
|
|
@ -9,6 +9,7 @@ tags:
|
||||||
- écoconception
|
- écoconception
|
||||||
authors:
|
authors:
|
||||||
- Margaux Escande
|
- Margaux Escande
|
||||||
|
draft: false
|
||||||
layout: article.njk
|
layout: article.njk
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ authors:
|
||||||
- Anne Faubry
|
- Anne Faubry
|
||||||
- Aurélie Baton
|
- Aurélie Baton
|
||||||
- Nicolas Doby
|
- Nicolas Doby
|
||||||
|
draft: false
|
||||||
layout: article.njk
|
layout: article.njk
|
||||||
---
|
---
|
||||||
En 2022, nous avons conçu et développé le site ["Celtique ? L'expo"](https://www.exposition-celtique.bzh) dans une
|
En 2022, nous avons conçu et développé le site ["Celtique ? L'expo"](https://www.exposition-celtique.bzh) dans une
|
||||||
|
|
|
@ -9,6 +9,7 @@ tags:
|
||||||
- ACV
|
- ACV
|
||||||
authors:
|
authors:
|
||||||
- Anthony Lecerf
|
- Anthony Lecerf
|
||||||
|
draft: false
|
||||||
layout: article.njk
|
layout: article.njk
|
||||||
---
|
---
|
||||||
Le numérique est au cœur de notre quotidien et bouleverse nos modes de vie et de travail. Il a également des effets
|
Le numérique est au cœur de notre quotidien et bouleverse nos modes de vie et de travail. Il a également des effets
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
title: "Test"
|
||||||
|
description: "test"
|
||||||
|
date: 2022-11-25
|
||||||
|
tags:
|
||||||
|
- test
|
||||||
|
- test2
|
||||||
|
- test3
|
||||||
|
authors:
|
||||||
|
- John Doe
|
||||||
|
draft: true
|
||||||
|
layout: article.njk
|
||||||
|
---
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus deleniti eius, eveniet fugit magni provident
|
||||||
|
vel? Corporis deserunt doloribus ducimus hic iusto nemo neque perspiciatis qui sit totam! Culpa, saepe!
|
||||||
|
|
||||||
|
Accusamus consectetur consequatur cupiditate est neque nisi pariatur possimus quisquam quod ratione. Atque dolorem
|
||||||
|
eius excepturi explicabo, illo, inventore ipsam laborum maxime molestias nisi omnis possimus sequi temporibus ut vero.
|
||||||
|
|
||||||
|
Accusantium aspernatur beatae commodi corporis, delectus dolore earum et explicabo illo illum ipsa ipsam iste magni
|
||||||
|
maiores minus neque omnis quis rem rerum sapiente sed ullam unde velit vitae voluptatum?
|
||||||
|
|
||||||
|
Atque, deserunt enim itaque laborum libero magnam minus pariatur quam, reiciendis repellat suscipit velit. Ad
|
||||||
|
aliquam debitis dolores fuga harum libero minus quaerat quam sequi velit! Recusandae rem, voluptatibus. Possimus?
|
||||||
|
|
||||||
|
Amet id itaque numquam obcaecati rem! Mollitia nostrum numquam quod. Aperiam assumenda, delectus dolor fuga fugiat,
|
||||||
|
iste maxime neque pariatur porro provident quaerat vitae voluptas? Dolorem quia quo tempore voluptatem.
|
|
@ -8,13 +8,13 @@ permalink: /blog/feed/feed.xml
|
||||||
<subtitle>{{ metadata.description }}</subtitle>
|
<subtitle>{{ metadata.description }}</subtitle>
|
||||||
<link href="{{ permalink | htmlBaseUrl(metadata.url) }}" rel="self"/>
|
<link href="{{ permalink | htmlBaseUrl(metadata.url) }}" rel="self"/>
|
||||||
<link href="{{ metadata.url | addPathPrefixToFullUrl }}"/>
|
<link href="{{ metadata.url | addPathPrefixToFullUrl }}"/>
|
||||||
<updated>{{ collections.articles | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
|
<updated>{{ collections.articles | filterDraft | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
|
||||||
<id>{{ metadata.url }}</id>
|
<id>{{ metadata.url }}</id>
|
||||||
<author>
|
<author>
|
||||||
<name>{{ metadata.author.name }}</name>
|
<name>{{ metadata.author.name }}</name>
|
||||||
<email>{{ metadata.author.email }}</email>
|
<email>{{ metadata.author.email }}</email>
|
||||||
</author>
|
</author>
|
||||||
{%- for article in collections.articles | reverse %}
|
{%- for article in collections.articles | filterDraft | reverse %}
|
||||||
{% set absolutePostUrl %}{{ article.url | htmlBaseUrl(metadata.url) }}{% endset %}
|
{% set absolutePostUrl %}{{ article.url | htmlBaseUrl(metadata.url) }}{% endset %}
|
||||||
<entry>
|
<entry>
|
||||||
<title>{{ article.data.title }}</title>
|
<title>{{ article.data.title }}</title>
|
||||||
|
|
|
@ -14,7 +14,7 @@ permalink: /blog/feed/feed.json
|
||||||
"url": "{{ metadata.author.url }}"
|
"url": "{{ metadata.author.url }}"
|
||||||
},
|
},
|
||||||
"items": [
|
"items": [
|
||||||
{%- for article in collections.articles | reverse %}
|
{%- for article in collections.articles | filterDraft | reverse %}
|
||||||
{%- set absoluteArticleUrl = article.url | htmlBaseUrl(metadata.url) %}
|
{%- set absoluteArticleUrl = article.url | htmlBaseUrl(metadata.url) %}
|
||||||
{
|
{
|
||||||
"id": "{{ absoluteArticleUrl }}",
|
"id": "{{ absoluteArticleUrl }}",
|
||||||
|
|
|
@ -10,7 +10,7 @@ eleventyNavigation:
|
||||||
<nav>
|
<nav>
|
||||||
{% include "tagslist.njk" %}
|
{% include "tagslist.njk" %}
|
||||||
</nav>
|
</nav>
|
||||||
{% set articlesList = collections.articles | head(-5) %}
|
{% set articlesList = collections.articles | filterDraft | head(-5) %}
|
||||||
{% include "articlesList.njk" %}
|
{% include "articlesList.njk" %}
|
||||||
</div>
|
</div>
|
||||||
<aside class="right-side">
|
<aside class="right-side">
|
||||||
|
|
Loading…
Reference in New Issue