meteor-sitemaps
meteor-sitemaps copied to clipboard
Possible to use iron router's pathFor?
Hi I recently tried to use the pathFor in a sitemap function with a trick like this:
var pathFor = UI._globalHelpers.pathFor;
out.push({
page: pathFor('home'),
lastmod: new Date(2015, 0, 1),
changefreq: 'daily',
priority: 0.5
});
But i get the error in console saying
(STDERR) pathFor couldn't find a route named undefined
Is there a proper way for this?
Hey, sorry for the late reply.
Actually I'm surprised this works at all... isn't all the UI stuff only available on the client? Sitemaps runs on the server. But I dunno, maybe since iron-router is installed in both places it makes a link.
Anyways, assuming you have access to the function, you need to recall that template helpers may expect a particular format (as provided by Meteor). So you actually need something like:
pathFor('home', {})
pathFor({ hash: { route: "home", data: ... } })
etc...
Hope this helps, but this is more an iron-router question than a sitemaps question.