How can I make Meteor templates available to targeted audiences via an URL?

 ̄綄美尐妖づ 提交于 2019-12-12 05:42:06

问题


I want to build a Blog, of sorts, with Meteor but, rather than just have a Blog such as platypus.meteor.com, I want to create a separate Meteor template for each Blog "post" and then send a link to select people such as "platypus.meteor.com/thispost"

In this way, the person would only see the post I intend them to see; to see others, they would have to guess at other values, such as "/thatpost", "/theotherpost" etc.

And in my case, if they stumbled across them, no big deal.

This is my plan:

Create one template at a time:

<template name="thispost">
    . . .
</template>

...and then allow access to that to whomever I apprise of its availability (that is, they simply enter the link I send them into their browser).

I don't know what sort of routing I need to set up; I'm open to either IronRouter or FlowRouter. At any rate, I want an URL like "platypus.meteor.com/thispost" (after a "meteor deploy platypus" of this project) to show the user the contents of that Template and nothing else.

So my question is: what do I have to do, routing-wise, to accomplish this?


回答1:


How about simply:

Router.route("/:templateName/:postId",{
  template: this.params.templateName,
  data: function(){ return Posts.findOne({ _id: this.params.postId })
});

Then you can generically share any post with any template and have the template name appear right in the route.



来源:https://stackoverflow.com/questions/32975999/how-can-i-make-meteor-templates-available-to-targeted-audiences-via-an-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!