add custom date filter
This commit is contained in:
parent
31dc4a5fbe
commit
32b43663f7
4 changed files with 10 additions and 4 deletions
|
|
@ -43,7 +43,7 @@ dont_show_lang_in_footer: true
|
||||||
<h2>{{ "recent-posts" | i18n }}</h2>
|
<h2>{{ "recent-posts" | i18n }}</h2>
|
||||||
<ul>
|
<ul>
|
||||||
{% for post in collections.posts | i18n_filter(5) %}
|
{% for post in collections.posts | i18n_filter(5) %}
|
||||||
<li><p><a href="{{ post.url }}">{{ post.data.title }}</a><br><span class="date"> {{ post.date.toLocaleString("en-GB", {year: 'numeric', month: '2-digit', day: '2-digit'}) }}</span></p></li>
|
<li><p><a href="{{ post.url }}">{{ post.data.title }}</a><br><span class="date"> {{ post.date | date("dd/MM/yyyy") }}</span></p></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const {
|
const { I18nPlugin } = require("@11ty/eleventy");
|
||||||
I18nPlugin
|
const { DateTime } = require("luxon");
|
||||||
} = require("@11ty/eleventy");
|
|
||||||
const i18n = require("eleventy-plugin-i18n");
|
const i18n = require("eleventy-plugin-i18n");
|
||||||
const eleventySass = require("eleventy-sass");
|
const eleventySass = require("eleventy-sass");
|
||||||
const toml = require("@iarna/toml");
|
const toml = require("@iarna/toml");
|
||||||
|
|
@ -35,6 +35,10 @@ module.exports = function (eleventyConfig) {
|
||||||
return filtered;
|
return filtered;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
eleventyConfig.addFilter("date", function (dateObj, format) {
|
||||||
|
return DateTime.fromJSDate(dateObj).toFormat(format);
|
||||||
|
});
|
||||||
|
|
||||||
eleventyConfig.addPlugin(eleventySass);
|
eleventyConfig.addPlugin(eleventySass);
|
||||||
eleventyConfig.addPlugin(I18nPlugin, {
|
eleventyConfig.addPlugin(I18nPlugin, {
|
||||||
defaultLanguage: defaultLanguage,
|
defaultLanguage: defaultLanguage,
|
||||||
|
|
|
||||||
1
package-lock.json
generated
1
package-lock.json
generated
|
|
@ -13,6 +13,7 @@
|
||||||
"@iarna/toml": "^2.2.5",
|
"@iarna/toml": "^2.2.5",
|
||||||
"eleventy-plugin-i18n": "^0.1.3",
|
"eleventy-plugin-i18n": "^0.1.3",
|
||||||
"eleventy-sass": "^3.0.0-beta.0",
|
"eleventy-sass": "^3.0.0-beta.0",
|
||||||
|
"luxon": "^3.7.2",
|
||||||
"markdown-it-emoji": "^3.0.0",
|
"markdown-it-emoji": "^3.0.0",
|
||||||
"markdown-it-emoji-customizer": "github:actuallysomecat/markdown-it-emoji-customizer",
|
"markdown-it-emoji-customizer": "github:actuallysomecat/markdown-it-emoji-customizer",
|
||||||
"sass": "^1.86.0"
|
"sass": "^1.86.0"
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
"@iarna/toml": "^2.2.5",
|
"@iarna/toml": "^2.2.5",
|
||||||
"eleventy-plugin-i18n": "^0.1.3",
|
"eleventy-plugin-i18n": "^0.1.3",
|
||||||
"eleventy-sass": "^3.0.0-beta.0",
|
"eleventy-sass": "^3.0.0-beta.0",
|
||||||
|
"luxon": "^3.7.2",
|
||||||
"markdown-it-emoji": "^3.0.0",
|
"markdown-it-emoji": "^3.0.0",
|
||||||
"markdown-it-emoji-customizer": "github:actuallysomecat/markdown-it-emoji-customizer",
|
"markdown-it-emoji-customizer": "github:actuallysomecat/markdown-it-emoji-customizer",
|
||||||
"sass": "^1.86.0"
|
"sass": "^1.86.0"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue