taxonomies - added taxonmies support

This commit is contained in:
James Ray 2021-08-15 10:52:43 -04:00
parent 8f239a0ddc
commit f420e5763c
6 changed files with 182 additions and 1 deletions

View file

@ -8,6 +8,12 @@ other = "Posts"
[toc_heading]
other = "Table of Contents"
[tags]
other = "Tags"
[categories]
other = "Categories"
[at]
other = "at"

View file

@ -54,7 +54,15 @@
<div class="title">
<h1>{{ .Page.Title }}</h1>
</div>
{{ if site.Params.enableTags }}
<div class="taxonomy-terms">
<ul class="taxonomy-terms">
{{ range .Params.tags }}
<li><a href="/tags/{{ . | urlize }}"><span class="tag-item">{{ . }}</span></a></li>
{{ end }}
</ul>
</div>
{{ end }}
<div class="post-content" id="post-content">
{{ .Page.Content }}
</div>

View file

@ -0,0 +1,62 @@
{{ define "header" }}
<link rel="stylesheet" href="{{ "/css/layouts/list.css" | relURL }}">
<link rel="stylesheet" href="{{ "/css/navigators/sidebar.css" | relURL}}">
<!--================= custom style overrides =========================-->
<link rel="stylesheet" href="{{ "/css/style.css" | relURL }}"/>
{{ end }}
{{ define "navbar" }}
{{ partial "navigators/navbar-2.html" . }}
{{ end }}
{{ define "sidebar" }}
{{ $homePage:="#" }}
{{ if site.IsMultiLingual }}
{{ $homePage = (path.Join (cond ( eq .Language.Lang "en") "" .Language.Lang) .Type) }}
{{ end }}
<section class="sidebar-section" id="sidebar-section">
<div class="sidebar-holder">
<div class="sidebar" id="sidebar">
<form class="mx-auto" method="get" action="{{ "search" | relLangURL }}">
<input type="text" name="keyword" value="" placeholder="Search" data-search="" id="search-box" />
</form>
<div class="sidebar-tree">
<ul class="tree" id="tree">
<li id="list-heading"><a href="{{ .Type | relLangURL }}" data-filter="all">{{ i18n .Type }}</a></li>
<div class="subtree taxonomy-terms">
{{ $context := . }}
{{ partial "navigators/taxonomies.html" (dict "context" $context "taxo" "categories" "title" ( humanize "categories" ) ) }}
</div>
</ul>
</div>
</div>
</div>
</section>
{{ end }}
{{ define "content" }}
<section class="content-section" id="content-section">
<div class="content container-fluid" id="content">
<div class="container-fluid post-card-holder" id="post-card-holder">
{{ $posts := where .RegularPagesRecursive "Layout" "!=" "search" }}
{{ $paginator := .Paginate $posts 12 }}
{{ range $paginator.Pages }}
{{ if .Layout }}
{{/* ignore the search.md file*/}}
{{ else }}
{{ partial "cards/post.html" . }}
{{ end }}
{{ end }}
</div>
<div class="paginator">
{{ template "_internal/pagination.html" . }}
</div>
</div>
</section>
{{ end }}
{{ define "scripts" }}
<script src="{{ "/js/list.js" | relURL }}"></script>
{{ end }}

View file

@ -0,0 +1,11 @@
{{ $context := .context }}
{{ $taxo := .taxo }}
{{ $title := .title }}
{{ if isset $context.Site.Taxonomies ( lower $taxo ) }}
{{ $taxonomy := index $context.Site.Taxonomies ( lower $taxo ) }}
{{ if (gt (len $taxonomy) 0)}}
{{ range $taxonomy }}
<li><a class="taxonomy-term" href="{{ .Page.Permalink }}" data-taxonomy-term="{{ urlize .Page.Title }}"><span class="taxonomy-label">{{ .Page.Title }}</span></a></li>
{{ end }}
{{ end }}
{{ end }}

62
layouts/tags/list.html Normal file
View file

@ -0,0 +1,62 @@
{{ define "header" }}
<link rel="stylesheet" href="{{ "/css/layouts/list.css" | relURL }}">
<link rel="stylesheet" href="{{ "/css/navigators/sidebar.css" | relURL}}">
<!--================= custom style overrides =========================-->
<link rel="stylesheet" href="{{ "/css/style.css" | relURL }}"/>
{{ end }}
{{ define "navbar" }}
{{ partial "navigators/navbar-2.html" . }}
{{ end }}
{{ define "sidebar" }}
{{ $homePage:="#" }}
{{ if site.IsMultiLingual }}
{{ $homePage = (path.Join (cond ( eq .Language.Lang "en") "" .Language.Lang) .Type) }}
{{ end }}
<section class="sidebar-section" id="sidebar-section">
<div class="sidebar-holder">
<div class="sidebar" id="sidebar">
<form class="mx-auto" method="get" action="{{ "search" | relLangURL }}">
<input type="text" name="keyword" value="" placeholder="Search" data-search="" id="search-box" />
</form>
<div class="sidebar-tree">
<ul class="tree" id="tree">
<li id="list-heading"><a href="{{ .Type | relLangURL }}" data-filter="all">{{ i18n .Type }}</a></li>
<div class="subtree taxonomy-terms">
{{ $context := . }}
{{ partial "navigators/taxonomies.html" (dict "context" $context "taxo" "tags" "title" ( humanize "tags" ) ) }}
</div>
</ul>
</div>
</div>
</div>
</section>
{{ end }}
{{ define "content" }}
<section class="content-section" id="content-section">
<div class="content container-fluid" id="content">
<div class="container-fluid post-card-holder" id="post-card-holder">
{{ $posts := where .RegularPagesRecursive "Layout" "!=" "search" }}
{{ $paginator := .Paginate $posts 12 }}
{{ range $paginator.Pages }}
{{ if .Layout }}
{{/* ignore the search.md file*/}}
{{ else }}
{{ partial "cards/post.html" . }}
{{ end }}
{{ end }}
</div>
<div class="paginator">
{{ template "_internal/pagination.html" . }}
</div>
</div>
</section>
{{ end }}
{{ define "scripts" }}
<script src="{{ "/js/list.js" | relURL }}"></script>
{{ end }}

View file

@ -236,6 +236,38 @@ h6 {
#scroll-to-top.show {
visibility: visible;
}
.taxonomy-terms {
text-align: center;
}
.taxonomy-terms li {
font-size: .8em;
list-style-type: none;
display: inline-block;
padding: .5em;
min-width: 5em;
margin: 0 .5em;
position: relative;
background: #8dd6dd;
border-radius: .4em;
}
.taxonomy-terms li:after {
content: '';
position: absolute;
left: 0;
top: 50%;
width: 0;
height: 0;
border: 10px solid transparent;
border-right-color: #8dd6dd;
border-left: 0;
margin-top: -10px;
margin-left: -10px;
}
.taxonomy-terms a{
color: black;
}
/* ============= Device specific fixes ======= */