Reorganise configurations for blog post categories
This commit is contained in:
parent
acfb762bdd
commit
e4dc17266e
@ -11,7 +11,7 @@ import { VentoPlugin } from 'eleventy-plugin-vento';
|
|||||||
// Custom Configurations
|
// Custom Configurations
|
||||||
import markdownItConfig from "./src/_config/markdown-it.js";
|
import markdownItConfig from "./src/_config/markdown-it.js";
|
||||||
import filesConfig from "./src/_config/files.js";
|
import filesConfig from "./src/_config/files.js";
|
||||||
import collectionsConfig from "./src/_config/collections.js";
|
import categoriesConfig from "./src/_config/categories.js";
|
||||||
import filtersConfig from "./src/_config/filters.js";
|
import filtersConfig from "./src/_config/filters.js";
|
||||||
import shortCodesConfig from "./src/_config/shortcodes.js";
|
import shortCodesConfig from "./src/_config/shortcodes.js";
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export default function(eleventyConfig) {
|
|||||||
// ----- Custom Configurations
|
// ----- Custom Configurations
|
||||||
eleventyConfig.addPlugin(markdownItConfig);
|
eleventyConfig.addPlugin(markdownItConfig);
|
||||||
eleventyConfig.addPlugin(filesConfig);
|
eleventyConfig.addPlugin(filesConfig);
|
||||||
eleventyConfig.addPlugin(collectionsConfig);
|
eleventyConfig.addPlugin(categoriesConfig);
|
||||||
eleventyConfig.addPlugin(filtersConfig);
|
eleventyConfig.addPlugin(filtersConfig);
|
||||||
eleventyConfig.addPlugin(shortCodesConfig);
|
eleventyConfig.addPlugin(shortCodesConfig);
|
||||||
|
|
||||||
|
@ -9,4 +9,14 @@ export default function(eleventyConfig) {
|
|||||||
});
|
});
|
||||||
return Array.from(categories).sort();
|
return Array.from(categories).sort();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
// Filter: Filter contents by category
|
||||||
|
eleventyConfig.addFilter("filterByCategory", function(contents, cat) {
|
||||||
|
cat = cat.toLowerCase();
|
||||||
|
let result = contents.filter(item => {
|
||||||
|
let cats = item.data.categories.map(c => c.toLowerCase());
|
||||||
|
return cats.includes(cat);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
}
|
@ -1,16 +1,6 @@
|
|||||||
import { DateTime } from "luxon";
|
import { DateTime } from "luxon";
|
||||||
|
|
||||||
export default function(eleventyConfig) {
|
export default function(eleventyConfig) {
|
||||||
// Filter: Filter contents by category
|
|
||||||
eleventyConfig.addFilter("filterByCategory", function(contents, cat) {
|
|
||||||
cat = cat.toLowerCase();
|
|
||||||
let result = contents.filter(item => {
|
|
||||||
let cats = item.data.categories.map(c => c.toLowerCase());
|
|
||||||
return cats.includes(cat);
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Filter: Format dates
|
// Filter: Format dates
|
||||||
eleventyConfig.addFilter("formatDate", (date) => {
|
eleventyConfig.addFilter("formatDate", (date) => {
|
||||||
const dateFormat = "d LLLL yyyy";
|
const dateFormat = "d LLLL yyyy";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user