Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON error #4

Open
lgwapnitsky opened this issue Jan 30, 2021 · 2 comments
Open

JSON error #4

lgwapnitsky opened this issue Jan 30, 2021 · 2 comments

Comments

@lgwapnitsky
Copy link

when running with documented config:

lgwapnitsky@blog:~/lgw_11ty$ eleventy-social-images --site-name "Larry G. Wapnitsky"
Starting social images...
(node:18860) UnhandledPromiseRejectionWarning: SyntaxError: /home/lgwapnitsky/lgw_11ty/pages.json: Unexpected number in JSON at position 1
    at parse (<anonymous>)
    at Object.Module._extensions..json (internal/modules/cjs/loader.js:1106:22)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at /home/lgwapnitsky/lgw_11ty/node_modules/@11tyrocks/eleventy-plugin-social-images/bin/social-images.js:82:17
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:18860) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:18860) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

pages.json file:

---
permalink: ./pages.json
permalinkBypassOutputDir: true
eleventyExcludeFromCollections: true
---
[
{%- for pages in collections.all %}
    {
      "title":"{{ pages.data.title | addNbsp | safe }}",
      "imgName":"{{ pages.data.title | slug }}"
    }{% if loop.last == false %},{% endif -%}
{% endfor %}
]
@5t3ph
Copy link
Owner

5t3ph commented Jan 30, 2021

Hi @lgwapnitsky - just to clarify, the file that creates the JSON should actually be a Nunjucks file (ex. pages.njk) and you may need to adjust your permalink to ensure it places it outside of your Eleventy input directory. There can also be issues with permalinks that aren't placed in quotes "./pages.json"

Check on those things, and let me know if you resolve it.

@lgwapnitsky
Copy link
Author

where would the njk file go and what would it look like? if i rename pages.json, i get an error that that file doesn't exist.

also, putting pages.json in quotes didn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants