{{ define "title" }}{{ .V.post.Title }}{{ end }}
{{ define "content" }}
{{ $Post := .V.post }}

<div class="card mb-4">
	<div class="card-header">
		<h1 class="blog-title">{{ $Post.Title }}</h1>
	</div>
	<div class="card-body">
		<small class="text-muted blog-meta"><em>
			{{ if $Post.Sticky }}<span class="blog-sticky">[sticky]</span>{{ end }}
			{{ if ne $Post.Privacy "public" }}
				<span class="blog-{{ $Post.Privacy }}">[{{ $Post.Privacy }}]</span>
			{{ end }}

			<span title="{{ $Post.CreatedAt.Format "Jan 2 2006 15:04:05 MST" }}">
				{{ $Post.CreatedAt.Format "January 2, 2006" }}
			</span>

			{{ if ($Post.UpdatedAt.After $Post.CreatedAt) }}
				<span title="{{ $Post.UpdatedAt.Format "Jan 2 2006 15:04:05 MST" }}">
				(updated {{ $Post.UpdatedAt.Format "January 2, 2006" }})
				</span>
			{{ end }}

			{{ if $Post.Author.Name }}
				by {{ $Post.Author.Name }}
			{{ end }}
		</em></small>
		<br><br>

		{{ $Post.HTML }}

		<div class="mt-4">
			<small class="text-muted"><em>
				Tags:

				{{ range $tag := $Post.Tags }}
					<a href="/tagged/{{ $tag.Tag }}" class="ml-2">#{{ $tag.Tag }}</a>
				{{ end }}
			</em></small>
		</div>
	</div>
</div>

{{ if .CurrentUser.IsAdmin }}
<div class="alert alert-secondary">
	<strong>Admin:</strong>
	[
		<a href="/blog/edit?id={{ $Post.ID }}">edit</a> |
		<a href="/blog/delete?id={{ $Post.ID }}">delete</a>
	]
</div>
{{ end }}

{{ $idStr := printf "%d" $Post.ID }}
{{ if $Post.EnableComments }}
	{{ RenderComments .ResponseWriter .Request $Post.Title "post" $idStr }}
{{ else }}
	{{ RenderCommentsRO .ResponseWriter .Request "post" $idStr }}
{{ end }}

{{ end }}
