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

website meta og:url is hardcoded to localhost and not using value from config #126

Closed
1 of 5 tasks
thescientist13 opened this issue Jul 13, 2019 · 2 comments · Fixed by #127
Closed
1 of 5 tasks
Assignees
Labels
bug Something isn't working P0 Critical issue that should get addressed ASAP

Comments

@thescientist13
Copy link
Member

thescientist13 commented Jul 13, 2019

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

When viewing source of the Greenwood website, the meta tag for og:url is hardcoded to localhost

<meta name="description" content="A modern and performant static site generator supporting Web Component based development"><meta name="twitter:site" content="@PrjEvergreen">
<meta property="og:tile" content="Greenwood"><meta property="og:type" content="website">
<meta property="og:url" content="http://127.0.0.1:8000/">
<meta property="og:image" content="https://s3.amazonaws.com/hosted.greenwoodjs.io/greenwood-logo.png">
<meta property="og:description" content="A modern and performant static site generator supporting Web Component based development">
<meta property="og:title" content="Greenwood"></head>

Details

Given a config like this, I would expect my URL to be used

module.exports = {
  ...

  meta: [
    ... 

    { property: 'og:url', content: 'https://www.greenwoodjs.io' },
  ]
};

related to #92

Did a quick scan of the code, and seems like is due to Greenwood hardcoding / overriding the user provided value perhaps?

// insert origin domain into url
if (metaPropValue === 'og:url') {
  metaContentVal = window.location.origin + metaContentVal;
}

Other thought is maybe this function is doing something unexpected?

const loadPageMeta = async (file, result, { metaComponent }) => {
  return new Promise((resolve, reject) => {
    try {
      const { title, meta, route } = file;
      const metadata = {
        title,
        meta
      };

      metadata.meta.push({ property: 'og:title', content: title });
      metadata.meta.push({ property: 'og:url', content: route });

      result = result.replace(/METAIMPORT/, `import '${metaComponent}'`);
      result = result.replace(/METADATA/, `const metadata = ${JSON.stringify(metadata)}`);
      result = result.replace(/METAELEMENT/, '<eve-meta .attributes=\${metadata}></eve-meta>');

      resolve(result);
    } catch (err) {
      reject(err);
    }
  });
};
@thescientist13 thescientist13 added the bug Something isn't working label Jul 13, 2019
@thescientist13 thescientist13 self-assigned this Jul 13, 2019
@thescientist13 thescientist13 added the P0 Critical issue that should get addressed ASAP label Jul 13, 2019
@hutchgrant
Copy link
Member

it's supposed to add the route for each page to the origin domain.

@thescientist13
Copy link
Member Author

thescientist13 commented Jul 13, 2019

Wrote a test (after a little refactoring) and confirmed the issue

it('should have our custom config <meta> tag with og:url property in the <head>', function() {
  const ogUrlMeta = metaFilter('og:url');
  const metaElement = dom.window.document.querySelector(`head meta[property="${ogUrlMeta.property}"]`);

  expect(metaElement.getAttribute('content')).to.be.equal(ogUrlMeta.content);
});
  Build Greenwood With:
    Custom Meta Configuration and Default Workspace
      Custom Meta Index Page
        ✓ should output an index.html file within the default hello page directory
        ✓ should have our custom config <meta> tag with og:site property in the <head>
        1) should have our custom config <meta> tag with og:url property in the <head>
        ✓ should have our custom config <meta> tag with twitter:site name in the <head>


  3 passing (5s)
  1 failing

  1) Build Greenwood With:
       Custom Meta Configuration and Default Workspace
         Custom Meta Index Page
           should have our custom config <meta> tag with og:url property in the <head>:

      AssertionError: expected 'http://127.0.0.1:8000/' to equal 'https://www.greenwoodjs.io'
      + expected - actual

      -http://127.0.0.1:8000/
      +https://www.greenwoodjs.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 Critical issue that should get addressed ASAP
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants