Skip to content

Commit

Permalink
readable date for noticias
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenreda committed Jun 7, 2024
1 parent 24e132c commit fec60d2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
28 changes: 20 additions & 8 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,25 @@ module.exports = function (eleventyConfig) {
return filtered;
});

eleventyConfig.addFilter("excludeServiceFilter", function (collection, service) {
if (!service) return collection;
const filtered = collection.filter((item) =>
!item.data.title.includes(service)
);
return filtered;
})
eleventyConfig.addFilter(
"excludeServiceFilter",
function (collection, service) {
if (!service) return collection;
const filtered = collection.filter(
(item) => !item.data.title.includes(service)
);
return filtered;
}
);

eleventyConfig.addFilter("formattedDate", function (value) {
const date = new Date(value);
return date.toLocaleDateString("es-ES", {
year: "numeric",
month: "long",
day: "numeric",
});
});

let options = {
html: true,
Expand All @@ -74,7 +86,7 @@ module.exports = function (eleventyConfig) {
};
eleventyConfig.setLibrary("md", markdownit(options));

eleventyConfig.addFilter("cssmin", function(code) {
eleventyConfig.addFilter("cssmin", function (code) {
return new CleanCSS({}).minify(code).styles;
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/noticia-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="content">
<div class="head">
<h4>{{ title }}</h4>
<p class="publish-date">{{ date }}</p>
<p class="publish-date">{{ date | formattedDate }}</p>
<p class="first-paragraph">{{ firstParagraph }}</p>
</div>
<div class="tail">
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/noticia.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<img class="head-image" src="{{image}}" alt="" />
<div class="content">
<h1>{{title}}</h1>
<p class="publish-date">{{ date }}</p>
<p class="publish-date">{{ date | formattedDate }}</p>
<div class="body">{{content}}</div>
</div>
</div>

0 comments on commit fec60d2

Please sign in to comment.