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

[object Promise] instead of link #3

Open
gleb-svechnikov opened this issue Oct 25, 2021 · 4 comments
Open

[object Promise] instead of link #3

gleb-svechnikov opened this issue Oct 25, 2021 · 4 comments

Comments

@gleb-svechnikov
Copy link

Hi, I've tried plugin but it returns [object Promise] instead of link into html. Any idea why?
Did I miss something in documentation?

@dc7290
Copy link

dc7290 commented Nov 2, 2021

@rcopstein

I think the PR here has something to do with it
#2

In Nunjucks, asynchronous and synchronous shortcodes are added in different ways.
However, since the PR here has been changed to universal shortcodes.
Nunjucks is now giving me errors.

To solve this, change it so that the following shortcode can be added only for "Nunjucks".

  eleventyConfig.addNunjucksAsyncShortcode('eleventyGoogleFonts', async (value) => {
    return await createInlineCss(value)
  })

@sarahg
Copy link

sarahg commented Nov 21, 2021

I ran into this as well. You can workaround this issue by downgrading to the previous release, like this:

npm install [email protected]

@rcopstein
Copy link
Contributor

I have to say, it's been a while since I last used eleventy, but as @dc7290 pointed out, we would need a special case for Nunjucks. I would suggest having both eleventyConfig.addNunjucksAsyncShortcode and eleventyConfig.addShortcode pointing to a common function, given that the universal shortcake works for both Liquid and JavaScript out of the box.

I'd say we could, roughly, have something like this:

let eleventyGoogleFontsShortcode = async (value) => {
    return await createInlineCss(value);
}

eleventyConfig.addShortcode('eleventyGoogleFonts', eleventyGoogleFontsShortcode);
eleventyConfig.addNunjucksAsyncShortcode('eleventyGoogleFonts', eleventyGoogleFontsShortcode);

This should add proper support for all engines, with the exception of Handlebars, which does not support async functions.

Any thoughts?

@charliegroll
Copy link

@takanorip this is still an open problem - any chance this will ever get addressed? for now, I'm reverting to 0.0.5 as @sarahg suggested (thanks btw)

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

5 participants