Skip to content

Help with organizing resources for a blog #3043

Answered by pdehaan
azangru asked this question in Q&A
Discussion options

You must be logged in to vote

Look on my Solutions, ye Mighty, and despair!

I ended up going with a custom filter solution since it seems like the filter is available in the this. scope when inside a directory data file. Seemed slightly more convenient than creating a ./helpers.js file that is imported in multiple files. 🤷

eleventy.config.js

/**
 * @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig
 * @returns {ReturnType<import("@11ty/eleventy/src/defaultConfig")>}
 */
module.exports = function (eleventyConfig) {
  eleventyConfig.addFilter("blogPermalink", function (filename = "") {
    return filename.replace(/^(\/?blog\/)[0-9]{4}\//, "$1");
  });

  eleventyConfig.addPassthroughCopy("src", {
    // deb…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@azangru
Comment options

@pdehaan
Comment options

@pdehaan
Comment options

@pdehaan
Comment options

Answer selected by azangru
@azangru
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants