eleventy-plugin-page-assets icon indicating copy to clipboard operation
eleventy-plugin-page-assets copied to clipboard

issues with directory mode

Open hidegh opened this issue 4 years ago • 5 comments

works with "source", but...not with directory mode

posts.zip

setup:

    const pageAssetsPlugin = require('eleventy-plugin-page-assets');

    eleventyConfig.addPlugin(pageAssetsPlugin, {
        mode: "directory",
        recursive: true,
        assetsMatching: "*.jpg|*.png",
        hashAssets: false,
        postsMatching: "src/posts/**/*.md",
    });

error:

`TypeError` was thrown:
    TypeError: Assignment to constant variable.
        at Template.transformDirectoryWalker (C:\$_Work\11ty-custom\node_modules\eleventy-plugin-page-assets\src\plugin.js:113:14)
        at async Template.runTransforms (C:\Users\Balazs\AppData\Roaming\npm\node_modules\@11ty\eleventy\src\Template.js:369:13)
        at async Template.renderPageEntry (C:\Users\Balazs\AppData\Roaming\npm\node_modules\@11ty\eleventy\src\Template.js:609:15)
        at async Template.writeMapEntry (C:\Users\Balazs\AppData\Roaming\npm\node_modules\@11ty\eleventy\src\Template.js:616:21)
        at async Promise.all (index 4)
        at async Eleventy.write (C:\Users\Balazs\AppData\Roaming\npm\node_modules\@11ty\eleventy\src\Eleventy.js:743:13)
        at async Eleventy.watch (C:\Users\Balazs\AppData\Roaming\npm\node_modules\@11ty\eleventy\src\Eleventy.js:650:5)
Wrote 0 files in 0.24 seconds (v0.11.1)

hidegh avatar Feb 13 '21 17:02 hidegh

Maybe it's fine, but there are two '*' signs in your postsMatching: src/posts/**/*.md.

And in docs it's only one '*': src/posts/*/*.md

dennis-8 avatar Apr 13 '21 05:04 dennis-8

I cannot get the plugin to work either unfortunately. Also seeing the above error. Running Mac OS.

For a temporary fix, until his PR is merged, I have solved this by replacing the npm package with @maxboeck repo.

npm i -D  https://github.com/maxboeck/eleventy-plugin-page-assets

chrissy-dev avatar Apr 26 '21 09:04 chrissy-dev

@scottishstoater

I've created my own simple plugin for this and it works: https://github.com/hidegh/jamstack-eleventy-custom/tree/master/src/plugins/eleventy-hugo-style-local-post-images

The repo contains a full 11ty site (base) built u from ZERO for a BLOGging site...

hidegh avatar Apr 26 '21 19:04 hidegh

Checked the network graph https://github.com/victornpb/eleventy-plugin-page-assets/network and found that maxboeck is the most up to date fork. I then switch the package.json and ran npm install after deleting the corresponding folder from node_module. This is because it has this specific commit which fixes this issue plus various other patches that was also accepted.

        "eleventy-plugin-page-assets": "github:maxboeck/eleventy-plugin-page-assets",

I did this because I was trying to use directory mode, after having issue with parse mode unexpectedly trying to parse 'absolute' path images instead of skipping over it. The context was I was trying to add footer images which is shared between pages and is not in a folder specific location.

mofosyne avatar Apr 01 '24 05:04 mofosyne