{{ define "main" }}
{{ if not (eq .Type "response" "bookmarkof")}}

{{ if ne .Type "article"}}<article class="post h-entry entry contents">{{else}}<article class="post longpost h-entry entry contents">{{end}}
  <section class="author" style="display:none">
    <a rel="author" class="p-author h-card" rel="me" href="https://jk.nipponalba.scot"><img src="/images/profile.jpg"/><div class="title">{{ .Site.Params.Author}}</div></a>
  </section>
      {{ if eq .Type "article" }}{{ with .Page.Params.images }}{{ partial "taxonomy/image.html" . }}{{ end }}<h3 class="p-name entry-title">{{ .Title }}</h3><b>{{ .Description }}</b>
          <section class="info">
          <span class="info-date"><time class="dt-published" datetime="{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 GMT" }}">{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 GMT" }}</time></span><span class="reading-time">{{ .ReadingTime }}-minute read</span><br/><br/>
          <span class="blogs_span">{{ with .Page.Params.Blog }}<i class="fa fa-pencil-square-o fa-1.5x fa-fw" aria-hidden="true" title="Tags"></i><b> {{ partial "taxonomy/blog.html" . }}{{ end }}</b></span><br/>
          <span class="categories_span">{{ with .Page.Params.category }}<i class="fa fa-tags fa-1.5x fa-fw" aria-hidden="true" title="Tags"></i>{{ partial "taxonomy/categories.html" . }}{{ end }}{{ with .Page.Params.tag }}, {{ partial "taxonomy/tags.html" . }}{{ end }}</span>
          </section>{{ end }}
<section class="e-content p-name">
  {{ .Content }}
  {{ if eq .Type "photo"}}
    <section class="photos">
    {{ range .Page.Params.Photo }}
    {{ if isset . "value" }}
      <a href="{{ .value }}"><img class="u-photo full" src="{{ .value }}" title="{{ .alt }}" alt="{{ .alt }}"/></a>
      {{ else }}
        <a href="{{ . }}"><img class="u-photo full" src="{{ . }}" title="Alt not yet added, will fix!" alt="Alt not yet added, will fix!"/></a>
    {{end}}
    {{end}}
    </section>
    {{end}}
    {{ if eq .Type "article" }}<section class="p-summary" style="display:none">
        {{ .Page.Params.summary }}<br/>
      </section>
    {{ end }}<br/>
</section>
{{ if not (eq .Type "article") }}<section class="info">
  <span class="info-date-other"><a href="{{ .Permalink }}" class="u-url"><time class="dt-published" datetime="{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 GMT" }}">{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 GMT" }}</time></a>
  <span class="syndication">
    {{ if or (isset .Page.Params "pleromaurl") (isset .Page.Params "pixelfedurl")}}
    - Syndication:
    {{ with .Page.Params.pleromaurl  }}<a rel="syndication" class="u-syndication" href="{{ . }}"><i class="fa fa-pleroma fa-1.5x fa-fw" aria-hidden="true" title="Pleroma"></i></a>{{ end }}
    {{ with .Page.Params.pixelfedurl  }}<a rel="syndication" class="u-syndication" href="{{ . }}"><i class="fa fa-pixelfed fa-1.5x fa-fw" aria-hidden="true" title="Pixelfed"></i></a>{{ end }}</span><span class="categories_span_other">{{ with .Page.Params.category }}{{ partial "taxonomy/categories.html" . }}{{ end }}{{ with .Page.Params.tag }}, {{ partial "taxonomy/tags.html" . }}{{ end }}
    {{ end }}</span></span>
    </section>{{ end }}
    <a class="u-url" style="display:none;" href="https://fed.brid.gy/">https://fed.brid.gy/</a>
</article>
<section id="interactions"><h4>Interactions</h4>
  <section id="interactions_intro">Interactions on this site are possible either via <a href="https://indieweb.org/Webmention" title="Webmention is a web standard for mentions and conversations across the web, a powerful building block that is used for a growing federated network of comments, likes, reposts, and other rich interactions across the decentralized social web." class="u-url" target="_blank">webmentions</a> or matrix courtesy of cactus chat, though guest (not logged in) commenting is not yet available.  Alternatively, contact me via <a href="https://matrix.to/#/@jk:nipponalba.scot" class="u-url" target="_blank">matrix</a> or <a href="mailto:jk@nipponalba.scot" class="u-url">email</a>.<br/><br/>
  <label for="toggle_webmentions" id="webmentions_label">Webmentions</label> | <label for="toggle_comments" id="comments_label">Comments</label></section>
  <input type="radio" name="interactions" id="toggle_webmentions" checked="checked"><input type="radio" name="interactions" id="toggle_comments">
<section id="webmentions_frame"><section id="webmention-form">
  <form action="https://webmention.io/jk.nipponalba.scot/webmention" method="post">
      <label>Did you mention this {{ .Type }} on your website? Put the URL of your post here:</label><br/>
      <input name="source" type="url"/>
      <input name="target" value="{{ .Permalink }}" type="hidden"/>
      <input value="Send Webmention" type="submit"/>
  </form>
  <p>Alternatively, if you do not have a webmentions enabled website then you can leave a message using the comment parade form below.</p>
<details><summary>Comment Parade</summary><p>Please copy the following and paste into the URL field below: <span class="url">{{.Permalink }}</span></p><embed type="text/html" class="commentparade" src="https://commentpara.de" /></details>
<p>All going well, interactions will take a few minutes to appear, possibly longer due to .. gremlins.</p>
</section>
{{ $mention_ids := index $.Site.Data.index .RelPermalink }}
{{ if isset $mention_ids 0}}
{{ $mentions := apply $mention_ids "index" $.Site.Data.mentions "." }}
{{ $mentions := sort $mentions "wm-received" }}
<section id="webmentions">
  <section class="like interaction"><h4>Likes</h4>{{ range $mentions }}{{ if eq (index . "wm-property") "like-of" }}
      <a href="{{ .author.url }}"><img class="remote_profile" src="{{ .author.photo }}" title="{{ .author.name }}" alt="{{ .author.name }}" /></a>{{ end}}
  {{ end }}</section>
  <section class="share interaction"><h4>Shares</h4>{{ range $mentions }}{{ if eq (index . "wm-property") "repost-of" }}
      <a href="{{ .author.url }}"><img class="remote_profile" src="{{ .author.photo }}" title="{{ .author.name }}" alt="{{ .author.name }}" /></a>{{ end}}
  {{ end }}</section>
  <h4>Comments & Replies</h4>{{ partial "webmention.html" $mentions }}
</section>{{ end }}</section>
<section id="comments_frame">
<div id="comment-section"></div>
<script>
     initComments({
            node: document.getElementById("comment-section"),
            defaultHomeserverUrl: "https://nipponalba.scot",
            serverName: "nipponalba.scot",
            siteName: "jk.nipponalba.scot",
            commentSectionId: "{{ .Page.Params.slug }}"
      })
</script></section>
</section></article>
{{ else if eq .Type "bookmarkof" }}
<section class="bookmarks">{{ $cats := slice }}
{{ range .Site.Data.bookmarks }}
  {{ $cats = $cats | append .category }}
{{ end }}
{{ $cats = uniq $cats | sort }}
{{ range $cats }}
    {{ $cat := . }}
    <section id="{{ $cat }}">
<h4>{{ $cat }}</h4>
    {{ range $.Site.Data.bookmarks }}
    {{ if eq .category $cat }}
<article data-post-type="bookmark-of" data-post-id="{{ .Params.slug }}" class="bookmark">
  <section class="author" style="display:none">
    <a rel="author" class="p-author h-card" rel="me" href="https://jk.nipponalba.scot"><img src="/images/profile.jpg"/><div class="title">{{ .Site.Params.Author}}</div></a>
  </section>
    <section class="h-entry">
      <a href="{{ (index . "bookmark-of") | absURL }}" class="u-bookmark-of" target="_blank">{{ .name }}</a> - <div class="p-name p-content">{{ .content | markdownify }}</div>
    </section>
</article>
{{ end }}
{{ end }}</section>
{{ end }}</section>
{{ else }}
<article class="{{ .Params.posttype }} h-entry entry" id="response">
      <section class="author" style="display:none;">
        <a rel="author" class="p-author  h-card" rel="me" href="https://jk.nipponalba.scot"><img src="/images/profile.jpg"/><div class="title">{{ .Site.Params.Title }}</div></a>
      </section>
      <section class="xrayReply"><p>{{ .Site.Params.Title }}
          {{ if eq .Params.posttype "like-of" }} liked  <i class="fa fa-thumbs-up fa-1.5x fa-fw" aria-hidden="true" title="Likes"></i> <a href="{{ .Params.xAuthorUrl }}" target="_blank">{{ .Params.xAuthor }}</a>'s <a href="{{ index .Params "like-of" }}" class="u-like-of u-target">{{ .Params.xPostType }}</a>{{ end }}
          {{ if eq .Params.posttype "in-reply-to" }} replied to  <i class="fa fa-comment fa-1.5x fa-fw" aria-hidden="true" title="Likes"></i> <a href="{{ .Params.xAuthorUrl }}" target="_blank">{{ .Params.xAuthor }}</a>'s <a href="{{ index .Params "in-reply-to" }}" class="u-in-reply-to u-target">{{ .Params.xPostType }}</a>{{ end }}
          {{ if eq .Params.posttype "repost-of"  }}  shared  <i class="fa fa-share fa-1.5x fa-fw" aria-hidden="true" title="Likes"></i> <a href="{{ .Params.xAuthorUrl }}" target="_blank">{{ .Params.xAuthor }}</a>'s <a href="{{ index .Params "repost-of" }}" class="u-repost-of u-target">{{ .Params.xPostType }}</a>{{ end }}</p>
          {{ if .Params.xContent }}<section class="replyContext"><span class="remotePhoto"><a href="{{ .Params.xAuthorUrl }}" target="_blank"><img src="{{ .Params.xPhoto }}" title="{{ .Params.xAuthor }}" alt="{{ .Params.xAuthor }}'s avatar"/></a></span><span class="response-date">{{ .Params.xPublished }}</span><span class="response-text">{{ plainify .Params.xContent  }}
          {{ if .Params.xContentPhoto }}<br/><br/>{{ range .Params.xContentPhoto }}<img class="u-photo xContentPhoto" src="{{ . }}"/>{{ end }}{{ end }}</span></section><br/>{{end}}
          {{ if .Content }}<section class="e-content p-name">{{ .Content }}</section>{{ end }}
          </section>
          {{ if not (eq .Type "article") }}<section class="info">
          </section>{{ end }}
              <span class="categories_span">{{ with .Page.Params.category }}Categories: {{ partial "taxonomy/categories.html" . }}{{ end }}</span><span class="info-date"><a href="{{ .Permalink }}" class="u-url"><time class="dt-published" datetime="{{ .Date.Format "2 Jan 2006 15:04 GMT" }}">{{ .Date.Format "02/01/2006 15:04 GMT" }}</time></a></span><br/>
        <a class="u-url" style="display:none;" href="https://fed.brid.gy/">https://fed.brid.gy/</a>
      </article>
                      {{end}}

{{end}}