dmkanerer
dmkanerer

Reputation: 141

How to have Semantic URLs for generated html pages in meteor?

When using python and Django I recall there being a way to use views with the http requests to make is so there would be a generated url for any webpage that was generated, say like a user profile or something like that. Is there a way for me to do this when using meteor JS? Any help would be great, just a link to an article would do, I cant seem to find anything about it.

Upvotes: 0

Views: 68

Answers (1)

hwillson
hwillson

Reputation: 1399

There isn't anything out of the box that will generate URL's for you, since this functionality is tied to routing (and Meteor core doesn't provide routing). Since you're using FlowRouter, you might want to take a look at the arillo:flow-router-helpers package. This package won't auto generate URL's for you, but it will give you URL helpers that you can leverage inside your Template's (Blaze), to make it easier to generate URL's for links. A few quick examples from their docs:

{{pathFor}}

<a href="{{pathFor '/post/:id' id=_id}}">Link to post</a>
<a href="{{pathFor 'postRouteName' id=_id}}">Link to post</a>
<a href="{{pathFor '/post/:id/comments/:cid' id=_id cid=comment._id}}">Link to comment in post</a>
<a href="{{pathFor '/post/:id/comments/:cid' id=_id cid=comment._id query='back=yes&more=true'}}">Link to comment in post with query params</a>

{{urlFor}}

Like pathFor but returns absolute URL's.

{{urlFor '/post/:id' id=_id}}

{{linkTo}}

{{#linkTo '/posts/'}}
  Go to posts
{{/linkTo}}

Upvotes: 1

Related Questions