ayal / headly

meteor package to handle facebookexternalhit responses (for og:metatags use)
28 stars 7 forks source link

attributes on <head> not supported #1

Closed iplanwebsites closed 11 years ago

iplanwebsites commented 11 years ago

Great lib!

In order to a custom object (not just "og:type"=websites), a prefix attribute is required on the head, but Meteor doesn't appreciate having on by default, and headly fails to inject it like the other meta tags.

Any clues on how it'd be possible to have Facebook gets the prefix attribute of the head element as specified in the open-graph examples?

iplanwebsites commented 11 years ago

for instance, here's the required HEAD for music.albums type:

 <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# music: http://ogp.me/ns/music#">
 <meta property="og:type"        content="music.album" />
iplanwebsites commented 11 years ago

Looks like the attribute is not mandatory, but it'd be curious to know how it'd be possible to access it.

ayal commented 11 years ago

@iplanwebsites I think this prefix is not needed It's not mentioned anywhere in the official documentation:

https://developers.facebook.com/docs/opengraphprotocol/

but to directly answer your question, with headly out-of-the-box it's not possible. But you can do the code change yourself if you find where mrt put headly's code.. you can just change this chunk:

  if (head) {
            res.write('<head>');
            res.write(head);
            res.write('</head>');
            }

to this:

  if (head) {
            res.write(head);    
}

and then use it like so:

Meteor.headly.config({tagsForRequest: function(req) {
  ... do something dynamic here, i.e get title from db based on url param ...
  return '<head prefix='XXXYYY'><meta property="og:title" content="<DYNAMIC TITLE>" /></head>';
}});

just make sure you open/close/render the head tag correctly

iplanwebsites commented 11 years ago

Thanks @ayal ! That's very helpful!