question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How use contentFor in engines

See original GitHub issue

So, I have a engine with lazyLoading: false inside a fresh ember app. My engine have addons and one of them have the code below:

# index.js
/* eslint-env node */
'use strict';

module.exports = {
  name: 'ember-cli-neutral',

  contentFor(type, config) {
    if (type === 'head') {
      if (config.googleFonts) {
        let families = config.googleFonts.join('|');

        return '<link href="https://fonts.googleapis.com/css?family=' + families + '" rel="stylesheet">'; // eslint-disable-line
      }
    }
  }
};
# environment.js
/* eslint-env node */
'use strict';

module.exports = () => {
  const ENV = {
    googleFonts: [
      'Roboto:400,500'
    ]
  };

  return ENV;
};

If I run engine separately the link of google fonts works perfectly, but if I run inside the fresh ember app not.

Perhaps a feature for future or it’s outside the scope of this project?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
trentmwilliscommented, Aug 9, 2017

it seems somewhat odd to allow other addons to mutate the main apps index.html (considering that engines are essentially an isolation primitive)

Agreed. However, it also seems that we would want Engines to be able to use addons that have contentFor hooks. I’m not sure what the best solution here, but I lean towards enabling contentFor for an Engine’s addons for consistency, as I believe it is what users would expect.

0reactions
ascuddercommented, Aug 8, 2022

I wanted to add my support for allowing engines to use contentFor as well. One of our engines needs to pull in a 3rd party dependency by adding to the index.hrml file. My first thought was that “engines are just a kind of addon,” so I expected it would work, but was surprised to find out that it doesn’t work and to find this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

25 tips to optimize your content for people and search engines
Content optimization today should combine a user-first approach with a good grounding in SEO. Here's how to get the right balance.
Read more >
How to Optimize your Content For Users and Search Engines
In this video, you'll learn what is SEO content and the exact process to follow to optimize your content for search engines and...
Read more >
Should We Write Content for People or Search Engines?
Should you write content for people? Or shoud you write SEO content that's designed to rank in search engines? We've got your answer...
Read more >
How writers can optimize content for a variety of search engines
A walk through the complex process to understand and implement how you can optimize content for search engines beyond Google.
Read more >
How to successfully write content for people and search engines
Writing content for people and search engines is not easy. There are different aspects that must be considered for both techniques. Learn how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found