Explorar o código

taxonomies - added taxonmies support (#396)

* taxonomies -  added taxonmies support

* taxonomies -  add active class

* Update CSS

Signed-off-by: hossainemruz <hossainemruz@gmail.com>

* Fix tag link for multilingual mode + add translations

Signed-off-by: hossainemruz <hossainemruz@gmail.com>

Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
James Ray %!s(int64=3) %!d(string=hai) anos
pai
achega
7b92452e2b

+ 6 - 0
i18n/bn.toml

@@ -8,6 +8,12 @@ other = "পোষ্ট সমূহ"
 [toc_heading]
 other = "সুচিপত্র"
 
+[tags]
+other = "ট্যাগ সমুহ"
+
+[categories]
+other = "বিভাগ সমুহ"
+
 [resume]
 other = "আমার জীবনবৃত্তান্ত"
 

+ 6 - 0
i18n/de.toml

@@ -8,6 +8,12 @@ other = "Beiträge"
 [toc_heading]
 other = "Inhaltsverzeichnis"
 
+[tags]
+other = "Stichworte"
+
+[categories]
+other = "Kategorien"
+
 [at]
 other = "bei"
 

+ 6 - 0
i18n/en.toml

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

+ 6 - 0
i18n/es.toml

@@ -8,6 +8,12 @@ other = "Posts"
 [toc_heading]
 other = "Contenido"
 
+[tags]
+other = "Etiquetas"
+
+[categories]
+other = "Categorías"
+
 [at]
 other = "en"
 

+ 6 - 0
i18n/fr.toml

@@ -8,6 +8,12 @@ other = "Articles"
 [toc_heading]
 other = "Table des matières"
 
+[tags]
+other = "Mots clés"
+
+[categories]
+other = "Catégories"
+
 [at]
 other = "chez"
 

+ 6 - 0
i18n/hi.toml

@@ -8,6 +8,12 @@ other = "पोस्ट"
 [toc_heading]
 other = "विषयसूची"
 
+[tags]
+other = "टैग"
+
+[categories]
+other = "श्रेणियाँ"
+
 [at]
 other = "अन्य"
 

+ 6 - 0
i18n/id.toml

@@ -8,6 +8,12 @@ other = "Artikel"
 [toc_heading]
 other = "Daftar Isi"
 
+[tags]
+other = "Tags"
+
+[categories]
+other = "Kategori"
+
 [at]
 other = "at"
 

+ 6 - 0
i18n/it.toml

@@ -8,6 +8,12 @@ other = "Post"
 [toc_heading]
 other = "Contenuti"
 
+[tags]
+other = "Tags"
+
+[categories]
+other = "Categorie"
+
 [at]
 other = "presso"
 

+ 6 - 0
i18n/jp.toml

@@ -8,6 +8,12 @@ other = "記事"
 [toc_heading]
 other = "目次"
 
+[tags]
+other = "タグ"
+
+[categories]
+other = "カテゴリ"
+
 [resume]
 other = "職務経歴書"
 

+ 6 - 0
i18n/ko.toml

@@ -8,6 +8,12 @@ other = "게시글"
 [toc_heading]
 other = "목차"
 
+[tags]
+other = "태그"
+
+[categories]
+other = "카테고리"
+
 [at]
 other = "at"
 

+ 6 - 0
i18n/nl.toml

@@ -7,6 +7,12 @@ other = "Beiträge"
 [toc_heading]
 other = "Inhaltsverzeichnis"
 
+[tags]
+other = "Tags"
+
+[categories]
+other = "Categorieën"
+
 [at]
 other = "bei"
 

+ 6 - 0
i18n/ru.toml

@@ -8,6 +8,12 @@ other = "Посты"
 [toc_heading]
 other = "Оглавление"
 
+[tags]
+other = "Теги"
+
+[categories]
+other = "Категории"
+
 [at]
 other = "в"
 

+ 6 - 0
i18n/vn.toml

@@ -8,6 +8,12 @@ other = "Bài viết"
 [toc_heading]
 other = "Mục lục"
 
+[tags]
+other = "Thẻ"
+
+[categories]
+other = "Thể loại"
+
 [at]
 other = "tại"
 

+ 6 - 0
i18n/zh-cn.toml

@@ -8,6 +8,12 @@ other = "博文"
 [toc_heading]
 other = "目录"
 
+[tags]
+other = "标签"
+
+[categories]
+other = "类别"
+
 [at]
 other = "at"
 

+ 6 - 0
i18n/zh-tw.toml

@@ -8,6 +8,12 @@ other = "文章"
 [toc_heading]
 other = "目錄"
 
+[tags]
+other = "标签"
+
+[categories]
+other = "类别"
+
 [at]
 other = "at"
 

+ 10 - 1
layouts/_default/single.html

@@ -54,7 +54,16 @@
         <div class="title">
           <h1>{{ .Page.Title }}</h1>
         </div>
-
+        {{ if site.Params.enableTags }}
+        <div class="taxonomy-terms">
+            <ul>
+            {{ range .Params.tags }}
+            {{ $url:= printf "tags/%s" . }}
+            <li class="rounded"><a href="{{ $url | urlize | relLangURL }}" class="btn, btn-sm">{{ . }}</a></li>
+            {{ end }}
+          </ul>
+        </div>
+        {{ end }}
         <div class="post-content" id="post-content">
           {{ .Page.Content }}
         </div>

+ 62 - 0
layouts/categories/list.html

@@ -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 }}

+ 15 - 0
layouts/partials/navigators/taxonomies.html

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

+ 62 - 0
layouts/tags/list.html

@@ -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 }}

+ 13 - 0
static/css/layouts/single.css

@@ -236,6 +236,19 @@ 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;
+	background: #248aaa;
+}
+
+.taxonomy-terms a{
+  color: #f9fafc;
+}
 
 /* ============= Device specific fixes ======= */