victornpb / eleventy-plugin-page-assets

MIT License
21 stars 16 forks source link

issues with directory mode #3

Open hidegh opened 3 years ago

hidegh commented 3 years ago

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)
dennis-8 commented 3 years ago

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`

chrissy-dev commented 3 years ago

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
hidegh commented 3 years ago

@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...

mofosyne commented 8 months ago

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.