cmawhorter / fancy

1 stars 2 forks source link

If multiple route values exist page.url() returns a comma concat list #14

Open cmawhorter opened 8 years ago

cmawhorter commented 8 years ago
<meta key="route" value="/one"> 
<meta key="route" value="/two"> 

template

<a href="<%= page.url() %>">should be "/one" but is instead "/one,/two"</a>

Workaround is to specify a urlTemplate which overrides route <meta key="urlTemplate" value="/one">

Or to use an array index page.url()[0]

Or to use a theme helper theme.url(page) -> url(page) => { return page.url()[0]; }

cmawhorter commented 8 years ago

This is a little weirder than I thought and the workaround should be in the theme helper as such:

var theme = {
    url: function(page) {
      if (page.urlTemplate || page.routes <= 1) {
        return page.url();
      }
      else {
        return page.route[0];
      }
    }
};

That should work for most scenarios and allow for:

ejs

<link rel="canonical" href="<%= theme.url(page) %>"> // 
<link rel="canonical" href="/one"> //