View Page

Remember to check out the documentation for restdb.io Pages and for restdb.io Querying. You can also view the master template source code.

{{#context}}
{
  "blogposts": {
      "collection": "blogposts",
      {{#if request.query.searchterm}}
            "query": {"published": true,"_tags": {"$regex": "{{_ "replace" request.query.searchterm " " "|"}}"}},
        {{else}}
            "query": {"published": true},
      {{/if}}
      "hints": {"$orderby": {"date": -1}}
  },
  "settings":{
        "collection": "settings",
        "query":{},
        "as":{
            "type":"map",
            "key":"name"
        }
  }
}
{{/context}}
{{#inherit "layout"}}
    {{#block "title"}}
        {{#unless blogposts}}
        <h2>No blogposts found matching "{{request.query.searchterm}}"</h2>
        {{/unless}} 
    {{/block}}
    {{#block "content"}}
        <div id="blogposts" class="col-md-12">
        {{#if request.query.searchterm}}
            {{#ifCond blogposts.length ">" 0}}
                <h3>{{blogposts.length}} article{{#ifCond blogposts.length ">" 1}}s{{/ifCond}} matches "{{request.query.searchterm}}"</h3>
            {{/ifCond}}                
        {{/if}}
        {{#each blogposts}}
           <div class="blog-post">
                <h3 class="title"><a class="" href="blog/{{slug}}">{{title}}</a></h3>
                <p class="author">by {{author.0.name}}<span> - {{moment date add="hours" amount="4" utc=true format="MMMM DD YYYY"}}</span>
                <img class="img-circle" src="/media/{{author.0.photo.[0]}}"></p>
                <div class="teaser">{{{teaser}}}</div>
                <p class="actions">
                    <a class="" href="blog/{{slug}}">Read more</a>
                </p>
            </div>
        {{/each}}
        </div>
    {{/block}}
    {{#block "sidebar"}}
    <p class="sidebar-header">
        <a title="RSS feed" href="{{root}}/rss"><i class="fa fa-rss-square fa-lg"></i></a>&nbsp;&nbsp;Subscribe to the RSS feed 
        <p><small>(the feed was created using a <a href="https://restdb.io/docs/Pages">restdb.io Page</a> with XML and Handlebars) - <a href="{{root}}/blog/create-rss-feed-in-restdb-io">view source</a></small></p>
        </p> 
        <div class="well">
          <h4>Blog Search</h4>
          <form id="blogsearch-form" method="GET">
            <div class="input-group">
              <input name="searchterm" type="text" class="form-control" value="{{request.query.searchterm}}"/><span class="input-group-btn">
                <button type="submit" class="btn btn-default"><span class="fa fa-search"></span></button></span>
            </div>
          </form>
        </div>
        <div class="well">
          <p><img src="/media/5798d93c8783df440000026c" width="140" style="margin-bottom:10px"/></p>
          {{{settings.[about-box].htmlvalue}}}
          {{#include "sharing-partial"}}
          {{/include}}
        </div>
      {{#include "resources-partial"}}
      {{/include}}
    {{/block}}
{{/inherit}}