generated from inherentlee/11ty
big ol copy
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { HtmlBasePlugin } from "@11ty/eleventy";
|
||||
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img";
|
||||
import pluginNavigation from "@11ty/eleventy-navigation";
|
||||
|
||||
import { attrs } from "@mdit/plugin-attrs";
|
||||
import { markdownitLinkAttributes } from 'markdown-it-link-attributes';
|
||||
import markdownitIdAttributes from "markdown-it-anchor";
|
||||
|
||||
import path from "node:path";
|
||||
import { chunk } from "lodash-es";
|
||||
|
||||
import pluginFilters from "./_config/filters.js";
|
||||
|
||||
@@ -43,6 +45,32 @@ export default async function (eleventyConfig) {
|
||||
bundleHtmlContentFromSelector: "script",
|
||||
});
|
||||
|
||||
/* Paginate tags */
|
||||
eleventyConfig.addCollection("doublePagination", function(collection) {
|
||||
// Get unique list of tags
|
||||
let tagSet = new Set(collection.getAllSorted().flatMap((post) => post.data.tags || []));
|
||||
|
||||
// Get each item that matches the tag
|
||||
let paginationSize = 20;
|
||||
let tagMap = [];
|
||||
let tagArray = [...tagSet];
|
||||
for( let tagName of tagArray) {
|
||||
let tagItems = collection.getFilteredByTag(tagName);
|
||||
let pagedItems = chunk(tagItems.reverse(), paginationSize); // console.log( tagName, tagItems.length, pagedItems.length );
|
||||
for( let pageNumber = 0, max = pagedItems.length; pageNumber < max; pageNumber++) {
|
||||
tagMap.push({
|
||||
tagName: tagName,
|
||||
pageNumber: pageNumber,
|
||||
pageSize: pagedItems.length,
|
||||
pageData: pagedItems[pageNumber]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//console.log( tagMap );
|
||||
return tagMap;
|
||||
});
|
||||
|
||||
/* Passthroughs */
|
||||
eleventyConfig
|
||||
.addPassthroughCopy("favicon.ico")
|
||||
@@ -76,6 +104,9 @@ export default async function (eleventyConfig) {
|
||||
},
|
||||
});
|
||||
|
||||
/* Navigation */
|
||||
eleventyConfig.addPlugin(pluginNavigation);
|
||||
|
||||
/* All filters from _config/filters.js */
|
||||
eleventyConfig.addPlugin(pluginFilters);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user