fix relative urls and make partials for article info

This commit is contained in:
Dmitry Kolosov 2020-02-18 20:52:31 +03:00
parent cc3c20d597
commit 9f0279bfe1
8 changed files with 38 additions and 81 deletions

View File

@ -1,38 +1,16 @@
{{ define "main" }}
<h1>{{ i18n .Title }}</h1>
{{ range (.Site.RegularPages.GroupByPublishDate "2006") }}
{{ range .Pages }}
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
{{ range $pages }}
<div class="post-short-list">
<header>
<h2>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h2>
</header>
<div class="article-info">
{{ if .Params.date }}
<div class="article-date">{{ .Params.date.Format "2006-01-02" }}</div>
{{ end }}
<div class="article-taxonomies">
{{ if .Params.categories }}
<ul class="article-categories">
{{ range .Params.categories }}
<li><a href="categories/{{ . }}">{{ . }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ if .Params.tags }}
<ul class="article-tags">
{{ range .Params.tags }}
<li><a href="tags/{{ . }}">#{{ . }}</a></li>
{{ end }}
</ul>
{{ end }}
</div>
</div>
{{ partial "articleInfoFull.html" . }}
</div>
{{ end }}
{{ end }}
{{ end }}

View File

@ -7,27 +7,7 @@
<div class="content">
{{ .Content }}
</div>
<div class="article-info">
{{ if .Params.date }}
<div class="article-date">{{ .Params.date.Format "2006-01-02" }}</div>
{{ end }}
<div class="article-taxonomies">
{{ if .Params.categories }}
<ul class="article-categories">
{{ range .Params.categories }}
<li><a href="categories/{{ . }}">{{ . }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ if .Params.tags }}
<ul class="article-tags">
{{ range .Params.tags }}
<li><a href="tags/{{ . }}">#{{ . }}</a></li>
{{ end }}
</ul>
{{ end }}
</div>
</div>
{{ partial "articleInfoFull.html" . }}
</article>
{{ if .Site.DisqusShortname }}
{{ template "_internal/disqus.html" . }}

View File

@ -16,27 +16,8 @@
<a href="{{ .RelPermalink }}">{{ i18n "readMore" | humanize }}</a>
</div>
{{ end }} -->
<div class="article-info">
{{ if .Params.date }}
<div class="article-date">{{ .Params.date.Format "2006-01-02" }}</div>
{{ end }}
<div class="article-taxonomies">
{{ if .Params.categories }}
<ul class="article-categories">
{{ range .Params.categories }}
<li><a href="categories/{{ . }}">{{ . }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ if .Params.tags }}
<ul class="article-tags">
{{ range .Params.tags }}
<li><a href="tags/{{ . }}">#{{ . }}</a></li>
{{ end }}
</ul>
{{ end }}
</div>
</div>
{{ partial "articleInfoFull.html" . }}
</article>
{{ end }}
{{ partial "pagination.html" . }}

View File

@ -0,0 +1,5 @@
<div class="article-info">
{{ if .Params.date }}
<div class="article-date">{{ .Params.date.Format "2006-01-02" }}</div>
{{ end }}
</div>

View File

@ -0,0 +1,21 @@
<div class="article-info">
{{ if .Params.date }}
<div class="article-date">{{ .Params.date.Format "2006-01-02" }}</div>
{{ end }}
<div class="article-taxonomies">
{{ if .Params.categories }}
<ul class="article-categories">
{{ range .Params.categories }}
<li><a href="{{ "categories/" | absURL }}{{ . }}">{{ . }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ if .Params.tags }}
<ul class="article-tags">
{{ range .Params.tags }}
<li><a href="{{ "tags/" | absURL }}{{ . }}">#{{ . }}</a></li>
{{ end }}
</ul>
{{ end }}
</div>
</div>

View File

@ -7,13 +7,13 @@
{{ if eq .Paginator.PageNumber 2 }}
<a href="{{ .Site.BaseURL }}{{ .Site.LanguagePrefix }}">{{ $toNewPostsMessage }}</a>
{{ else }}
<a href="{{ .Paginator.Prev.URL }}">{{ $toNewPostsMessage }}</a>
<a href="{{ .Paginator.Prev.URL | absURL }}">{{ $toNewPostsMessage }}</a>
{{ end }}
{{ end }}
</div>
<div class="right pagination-item {{ if not .Paginator.HasNext }}disabled{{ end }}">
{{ if .Paginator.HasNext }}
<a href="{{ .Paginator.Next.URL }}">{{ $toOldPostsMessage }}</a>
<a href="{{ .Paginator.Next.URL | absURL }}">{{ $toOldPostsMessage }}</a>
{{ end }}
</div>
</div>

View File

@ -2,7 +2,7 @@
<h1>{{ i18n "category" | humanize }}: {{ .Title }}</h1>
<div class="article-info">
<a href="categories/">{{ i18n "toAllCategories" | humanize }}</a>
<a href="{{ "categories/" | absURL }}">{{ i18n "toAllCategories" | humanize }}</a>
</div>
{{ range .Data.Pages }}
<article class="post-list">
@ -15,11 +15,7 @@
<div class="content">
{{ .Summary }}
</div>
<div class="article-info">
{{ if .Params.date }}
<div class="article-date">{{ .Params.date.Format "2006-01-02" }}</div>
{{ end }}
</div>
{{ partial "articleInfoDate.html" . }}
<!-- {{ if .Truncated }}
<div class="read-more">
<a href="{{ .RelPermalink }}">{{ i18n "readMore" | humanize }}</a>

View File

@ -2,7 +2,7 @@
<h1>{{ i18n "tag" | humanize }}: {{ .Title }}</h1>
<div class="article-info">
<a href="tags/">{{ i18n "toAllTags" | humanize}}</a>
<a href="{{ "tags/" | absURL }}">{{ i18n "toAllTags" | humanize}}</a>
</div>
{{ range .Data.Pages }}
<article class="post-list">
@ -14,11 +14,7 @@
<div class="content">
{{ .Summary }}
</div>
<div class="article-info">
{{ if .Params.date }}
<div class="article-date">{{ .Params.date.Format "2006-01-02" }}</div>
{{ end }}
</div>
{{ partial "articleInfoDate.html" . }}
<!-- {{ if .Truncated }}
<div class="read-more">
<a href="{{ .RelPermalink }}">{{ i18n "readMore" | humanize }}</a>