Adding admin functionality to our templates
The best way to allow editing of our post is to add an Edit post link to our post's page, which can only be seen if we are logged in. This way, we save rebuilding a similar infrastructure for an additional backend, and make it easy to use as there is no strong separation between frontend and backend.
First, we will add a Create new post link to our home
template, then add the Edit post link to the post's pages
template, and finally add the login buttons and form to the main menu.
Adding a link for new posts
Let's begin by adding a Create new post link. Open the home
template at my-meteor-blog/clients/templates/home.html
and add the following lines of code just above the {{#each postsList}}
block helper:
{{#if currentUser}} <a href="/create-post" class="createNewPost">Create new post</a> {{/if}}
The {{currentUser}}
helper comes with the accounts-base
package, which was installed when we installed our accounts
packages. It will return...