How to create a new page/route on the fly and display it as "preview"?


#1

Similar to a WordPress post/page editor:

  • I have an app that lets users edit HTML.
  • I would like to have them preview it as a separate page with temporary route (that no other can access later)
  • Once finalized, I need to save the edited HTML into a page of its own, with its own slug / route

Now, what is the right approach / packages to solve this correctly?


#2

You can have a route with dynamic parts. For iron:router you find the documentation about it here. There are also other routers that you can find on Atmosphere.


#3

Thanks @Sanjo It is helpful.


#4

I’d store the content in a collection (or even embed it in the users collection as a hashtable, where a token is the key)

then, I’d create a dynamic route, something along: ‘/my-page/:token’, and utilize Iron Router to control access to it (i.e. checking the user id etc)

you might also allow users to add titles, and then use the titles to automatically generate permalinks to their finalized page
e.g. title = “cooking is fun” -> permalink = “cooking-is-fun”


#5

Thanks @chenroth I will explore the collections and router methodology.