Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wangchucheng/hugo-eureka.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWang Chucheng <ccwangchn@gmail.com>2020-10-16 07:06:37 +0300
committerWang Chucheng <ccwangchn@gmail.com>2020-10-16 07:06:37 +0300
commit8987983acd6c668ad30c88409ee75f5c978e3d6c (patch)
treea6941cca861b9a2ca1302cb5e61481883b731adc /layouts
parent89640f682b3c2f7f092ea7f630934120e14beae0 (diff)
feat: add doc layout
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/baseof.html2
-rw-r--r--layouts/docs/doc_list.html (renamed from layouts/_default/section.html)2
-rw-r--r--layouts/docs/list.html3
-rw-r--r--layouts/docs/single.html3
-rw-r--r--layouts/partials/doc_layout.html93
-rw-r--r--layouts/partials/doc_toc.html11
-rw-r--r--layouts/partials/horizontal_summary.html30
-rw-r--r--layouts/partials/post_toc.html2
-rw-r--r--layouts/partials/schema.html4
-rw-r--r--layouts/partials/schema_node.html1
10 files changed, 144 insertions, 7 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 4daa892..b2e9074 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -3,7 +3,7 @@
{{- partial "head.html" . -}}
<body>
- <header class="flex items-center fixed w-full min-h-16 z-50 bg-secondary-bg shadow-sm">
+ <header class="flex items-center fixed w-full h-16 z-50 bg-secondary-bg shadow-sm">
<div class="container mx-auto">
<div class="max-w-screen-xl">
{{- partial "header.html" . -}}
diff --git a/layouts/_default/section.html b/layouts/docs/doc_list.html
index 710d7aa..0d02552 100644
--- a/layouts/_default/section.html
+++ b/layouts/docs/doc_list.html
@@ -1,6 +1,6 @@
{{ define "main" }}
<article class="mx-6 my-8">
- <h1 class="font-bold text-3xl text-primary-text">{{.Title}}</h1>
+ <h1 class="font-bold text-3xl text-primary-text">{{ .Title }}</h1>
{{ with .Content }}
<div class="content">
{{ . }}
diff --git a/layouts/docs/list.html b/layouts/docs/list.html
new file mode 100644
index 0000000..fcee3bb
--- /dev/null
+++ b/layouts/docs/list.html
@@ -0,0 +1,3 @@
+{{ define "main" }}
+{{ partial "doc_layout.html" . }}
+{{ end }} \ No newline at end of file
diff --git a/layouts/docs/single.html b/layouts/docs/single.html
new file mode 100644
index 0000000..6244028
--- /dev/null
+++ b/layouts/docs/single.html
@@ -0,0 +1,3 @@
+{{ define "main" }}
+{{ partial "doc_layout.html" . }}
+{{ end }}
diff --git a/layouts/partials/doc_layout.html b/layouts/partials/doc_layout.html
new file mode 100644
index 0000000..8e8225f
--- /dev/null
+++ b/layouts/partials/doc_layout.html
@@ -0,0 +1,93 @@
+{{ $hasToc := and (in .TableOfContents "<li>" ) (.Params.toc) }}
+{{ $hasSidebar := or ($hasToc) (.Params.series) }}
+<div class="lg:pt-12">
+ <div class="flex flex-col md:flex-row bg-secondary-bg rounded">
+ <div class="md:w-1/4 lg:w-1/5 border-r">
+ <div class="sticky top-16 pt-6">
+ {{ template "doc_sidebar" (dict "context" . "permalink" .Permalink) }}
+ </div>
+
+ </div>
+ <div class="w-full md:w-3/4 lg:w-4/5 pb-8 pt-2 md:pt-8">
+ <div class="w-full lg:w-3/4 pl-6 ml-0 mr-auto">
+ <h1 class="font-bold text-3xl text-primary-text">{{ .Title }}</h1>
+ {{ partial "post_metadata.html" . }}
+ </div>
+ <div class="flex">
+ <div class="w-full lg:w-3/4 px-6">
+ {{ $img := partial "get_image.html" (dict "context" . "url" .Params.featuredImage "keyword" "*featured*")}}
+ {{ with $img }}
+ <div class="my-4">
+ <img src="{{ . }}" class="w-full" alt="Featured Image">
+ </div>
+ {{ end }}
+ <div class="content">
+ {{ .Content}}
+ </div>
+ {{ with .GetTerms "tags" }}
+ {{ partial "post_tags.html" . }}
+ {{ end }}
+ {{ with .GetTerms "authors" }}
+ {{ partial "post_author.html" . }}
+ {{ end }}
+ {{ partial "post_footer.html" . }}
+ {{ partial "comment.html" . }}
+ </div>
+ {{ if $hasSidebar}}
+ <div class="hidden lg:block lg:w-1/4">
+ {{ if ne $hasToc false }}
+ {{ partial "doc_toc.html" . }}
+ {{ end }}
+ </div>
+ {{ end }}
+ </div>
+
+ </div>
+
+
+ </div>
+</div>
+
+<script>
+ document.addEventListener('DOMContentLoaded', () => {
+ hljs.initHighlightingOnLoad();
+ changeSidebarHeight();
+ switchDocToc();
+ })
+</script>
+
+{{ define "doc_sidebar" }}
+{{ if eq .context.Parent.Params.layout "doc_list" }}
+<div id="sidebar-title" class="md:hidden mx-4 px-2 pt-4 pb-2 md:border-b text-tertiary-text md:text-primary-text">
+ <span class="font-semibold">{{ i18n "toc" }}</span>
+ <i class="fas fa-caret-right ml-1"></i>
+</div>
+
+<div id="sidebar-toc"
+ class="hidden md:block overflow-y-auto mx-6 md:mx-0 pr-6 pt-2 md:max-h-doc-sidebar bg-primary-bg md:bg-transparent">
+ <div class="ml-4 -mr-2 p-2 bg-secondary-bg md:bg-primary-bg rounded">
+ <a class="{{ if eq .context.Permalink .permalink }}text-eureka{{ end }} hover:text-eureka" href="{{ .context.Permalink }}">{{ .context.Title }}</a>
+ </div>
+
+ {{ template "list_pages" (dict "context" .context "permalink" .permalink) }}
+</div>
+{{ else }}
+{{ template "doc_sidebar" (dict "context" .context.Parent "permalink" .permalink) }}
+{{ end }}
+{{ end }}
+
+{{ define "list_pages"}}
+<ul class="pl-6">
+ {{ range .context.Pages }}
+ <li class="py-2">
+ <div class="{{ if .IsSection }} pb-2 {{ end }}">
+ <a class="{{ if eq .Permalink $.permalink }} text-eureka {{ end }} hover:text-eureka"
+ href="{{ .Permalink }}">{{ .Title }}</a>
+ </div>
+ {{ if .IsSection }}
+ {{ template "list_pages" (dict "context" . "permalink" $.permalink) }}
+ {{ end }}
+ </li>
+ {{ end }}
+</ul>
+{{ end }} \ No newline at end of file
diff --git a/layouts/partials/doc_toc.html b/layouts/partials/doc_toc.html
new file mode 100644
index 0000000..61959eb
--- /dev/null
+++ b/layouts/partials/doc_toc.html
@@ -0,0 +1,11 @@
+<div class="sticky top-16 pt-16 -mt-16 bg-secondary-bg z-10 text-lg font-semibold hidden lg:block px-6 py-4">
+ <h2 class="subtitle">{{ i18n "onThisPage" }}</h2>
+</div>
+<div class="sticky-toc top-32 pt-10 -mt-10 hidden lg:block border-l px-6 pb-2 mb-4">
+ {{ .TableOfContents }}
+</div>
+<script>
+ window.addEventListener('DOMContentLoaded', () => {
+ enableStickyToc();
+ });
+</script> \ No newline at end of file
diff --git a/layouts/partials/horizontal_summary.html b/layouts/partials/horizontal_summary.html
index a4a45d3..5fb30ba 100644
--- a/layouts/partials/horizontal_summary.html
+++ b/layouts/partials/horizontal_summary.html
@@ -1,13 +1,37 @@
<div class="flex flex-col-reverse lg:flex-row justify-between">
- <div>
+ <div class="w-full">
<div class="my-2">
- <div class="font-bold text-xl text-primary-text mb-4"><a href="{{ .Permalink }}"
- class="hover:text-eureka">{{ .Title }}</a></div>
+ <div class="mb-4">
+ <a href="{{ .Permalink }}" class="font-bold text-xl hover:text-eureka">{{ .Title }}</a>
+ </div>
<div class="content">
{{ .Summary | plainify }}
</div>
</div>
+ {{ if eq .Type "docs" }}
+ <div class="px-6 pt-4">
+ {{ range $index, $value := first 3 .Pages }}
+ {{ if gt $index 0 }}
+ <div class="-mx-4 my-4 border-t"></div>
+ {{ end -}}
+ <div class="">
+ <div class="mb-2">
+ <a href="{{ .Permalink }}" class="font-semibold hover:text-eureka">{{ .Title }}</a>
+ </div>
+ <div class="">
+ {{- .Summary | plainify -}}
+ </div>
+ </div>
+ {{ end }}
+ <div class="pt-6 hover:text-eureka">
+ <a href="{{ .Permalink }}" class="font-semibold">{{ i18n "readMore" }}</a>
+ <i class="fas fa-caret-right ml-1"></i>
+ </div>
+
+ </div>
+ {{ else }}
{{ partial "post_metadata.html" . }}
+ {{ end }}
</div>
{{ $img := partial "get_image.html" (dict "context" . "url" .Params.featuredImage "keyword" "*featured*")}}
{{ with $img }}
diff --git a/layouts/partials/post_toc.html b/layouts/partials/post_toc.html
index 601a4f3..c4b126a 100644
--- a/layouts/partials/post_toc.html
+++ b/layouts/partials/post_toc.html
@@ -1,7 +1,7 @@
<div class="sticky top-16 z-10 text-lg font-semibold bg-primary-bg hidden lg:block px-6 py-4">
<h2 class="subtitle">{{ i18n "toc" }}</h2>
</div>
-<div class="sticky-toc hidden lg:block px-6 pb-6">
+<div class="sticky-toc top-32 hidden lg:block px-6 pb-6">
{{ .TableOfContents }}
</div>
<script>
diff --git a/layouts/partials/schema.html b/layouts/partials/schema.html
index 2c129da..e7aeaf5 100644
--- a/layouts/partials/schema.html
+++ b/layouts/partials/schema.html
@@ -18,7 +18,9 @@
</script>
{{ end }}
-{{ if or (eq .Kind "section") (eq .Kind "term") }}
+{{ if and (eq .Type "docs") (ne .Params.layout "doc_list") }}
+{{ partial "schema_page.html" . }}
+{{ else if or (eq .Kind "section") (eq .Kind "term") }}
{{ partial "schema_node.html" . }}
{{ else if .IsPage }}
{{ partial "schema_page.html" . }}
diff --git a/layouts/partials/schema_node.html b/layouts/partials/schema_node.html
index 3c3f7b5..f3a0f5e 100644
--- a/layouts/partials/schema_node.html
+++ b/layouts/partials/schema_node.html
@@ -1,3 +1,4 @@
+{{ $paginator := .Paginate .Pages }}
{{ with .Paginator.Pages }}
<script type="application/ld+json">
{