diff --git a/data/assets.toml b/data/assets.toml
index 25442a3d..3cbbf7db 100644
--- a/data/assets.toml
+++ b/data/assets.toml
@@ -59,6 +59,10 @@
version = "2.9.0"
sri = "sha256-cJXigylnJlxvAdfFNHeS+IiMcKWS3Rf/cy3bl9bb0ng="
url = "https://cdnjs.cloudflare.com/ajax/libs/instantsearch.js/%s/instantsearch.min.js"
+[js.anchor]
+ version = "4.1.1"
+ sri = "sha256-pB/deHc9CGfFpJRjC43imB29Rse8tak+5eXqntO94ck="
+ url = "https://cdnjs.cloudflare.com/ajax/libs/anchor-js/%s/anchor.min.js"
# CSS
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 33c6e645..139e33a5 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -280,8 +280,8 @@ enableGitInfo = false
weight = 4
[[menu.main]]
- name = "Teaching"
- url = "#teaching"
+ name = "Tutorials"
+ url = "/tutorial/"
weight = 5
[[menu.main]]
diff --git a/exampleSite/content/privacy.md b/exampleSite/content/privacy.md
index 4faa7e2a..56123fa3 100644
--- a/exampleSite/content/privacy.md
+++ b/exampleSite/content/privacy.md
@@ -2,7 +2,7 @@
title = "Privacy Policy"
date = 2018-06-28T00:00:00
-draft = false
+draft = true
# [header]
# image = ""
diff --git a/exampleSite/content/tutorial/_index.md b/exampleSite/content/tutorial/_index.md
new file mode 100644
index 00000000..0bcfc09c
--- /dev/null
+++ b/exampleSite/content/tutorial/_index.md
@@ -0,0 +1,33 @@
++++
+title = "Overview"
+
+date = 2018-09-09T00:00:00
+# lastmod = 2018-09-09T00:00:00
+
+draft = false # Is this a draft? true/false
+toc = true # Show table of contents? true/false
+type = "docs" # Do not modify.
+
+# Add menu entry to sidebar.
+[menu.docs]
+ name = "Overview"
+ weight = 1
+
+# Featured image.
+# Uncomment below lines to use.
+# [header]
+# image = "headers/getting-started.png"
+# caption = "Image credit: [**Academic**](https://github.com/gcushen/hugo-academic/)"
++++
+
+This feature can be used for publishing content such as:
+
+* **Project or software documentation**
+* **Online courses**
+* **Tutorials**
+
+The parent folder may be renamed, for example, to `docs` for project documentation or `course` for creating an online course.
+
+To disable this feature, either delete the parent folder, or set `draft = true` in the front matter of all its pages.
+
+After renaming or deleting the parent folder, you may wish to update any `[[menu.main]]` menu links to it in the `config.toml`.
diff --git a/exampleSite/content/tutorial/example.md b/exampleSite/content/tutorial/example.md
new file mode 100644
index 00000000..16947d5c
--- /dev/null
+++ b/exampleSite/content/tutorial/example.md
@@ -0,0 +1,32 @@
++++
+title = "Example Page"
+
+date = 2018-09-09T00:00:00
+# lastmod = 2018-09-09T00:00:00
+
+draft = false # Is this a draft? true/false
+toc = true # Show table of contents? true/false
+type = "docs" # Do not modify.
+
+# Add menu entry to sidebar.
+linktitle = "Example Page"
+[menu.docs]
+ parent = "Example Topic"
+ weight = 1
+
+# Featured image.
+# Uncomment below lines to use.
+# [header]
+# image = "headers/getting-started.png"
+# caption = "Image credit: [**Academic**](https://github.com/gcushen/hugo-academic/)"
++++
+
+In this tutorial, I'll share my top 10 tips for getting started with Academic:
+
+## Tip 1
+
+...
+
+## Tip 2
+
+...
diff --git a/i18n/en.yaml b/i18n/en.yaml
index c47fe0ea..6e48dbae 100644
--- a/i18n/en.yaml
+++ b/i18n/en.yaml
@@ -145,6 +145,9 @@
- id: search_placeholder
translation: Search...
+- id: search_results
+ translation: Search Results
+
- id: search_no_results
translation: No results found
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index c1f7fb35..4f006a78 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -9,9 +9,8 @@
{{ partial "header_image.html" . }}
-
-
- {{ with .Title }}
{{ . }}
{{ end }}
+
+ {{ with .Title }}
{{ . }}
{{ end }}
{{ with .Content }}
{{ . }}
@@ -34,7 +33,6 @@
{{ end }}
{{ partial "pagination" . }}
-
{{ partial "footer_container.html" . }}
{{ partial "footer.html" . }}
diff --git a/layouts/docs/list.html b/layouts/docs/list.html
new file mode 100644
index 00000000..6b6a6307
--- /dev/null
+++ b/layouts/docs/list.html
@@ -0,0 +1 @@
+{{ partial "docs_layout.html" . }}
diff --git a/layouts/docs/single.html b/layouts/docs/single.html
new file mode 100644
index 00000000..6b6a6307
--- /dev/null
+++ b/layouts/docs/single.html
@@ -0,0 +1 @@
+{{ partial "docs_layout.html" . }}
diff --git a/layouts/partials/css/academic.css b/layouts/partials/css/academic.css
index cd1f5cc5..a0228e0e 100644
--- a/layouts/partials/css/academic.css
+++ b/layouts/partials/css/academic.css
@@ -268,7 +268,7 @@ small,
overflow-x: hidden;
}
-#search-query {
+#search-box #search-query {
border: 1px solid #dedede;
border-radius: 1rem;
padding: 1rem 1rem 1rem 2rem; /* Wider left padding for search icon to fit in. */
@@ -299,6 +299,11 @@ small,
display: none;
}
+.form-control:focus {
+ border-color: {{ .Get "primary" }};
+ box-shadow: 0 0 0 .2rem {{ .Get "primary_light" }};
+}
+
/*************************************************
* Modals.
**************************************************/
@@ -1499,20 +1504,245 @@ div.alert a:hover {
}
+/*************************************************
+ * Documentation layout
+ **************************************************/
+
+.docs-article-container {
+ max-width: 760px;
+}
+
+/* Documentation: article footer. */
+
+.docs .body-footer {
+ border-top: 1px solid #e8e8e8;
+ margin-top: 30px;
+ padding-top: 10px;
+ font-size: 14px;
+ color: #707070;
+}
+
+/* Docs content. */
+
+.docs-content {
+ order: 1;
+ position: relative;
+}
+
+.docs-content>h2[id],
+.docs-content>h3[id],
+.docs-content>h4[id] {
+ pointer-events: none;
+}
+
+.docs-content>ol li,
+.docs-content>ul li {
+ margin-bottom: .25rem;
+}
+
+/* Docs search. */
+
+.docs-search {
+ position: relative;
+ padding: 1rem 15px;
+ margin-right: -15px;
+ margin-left: -15px;
+ border-bottom: 1px solid rgba(0, 0, 0, .05);
+}
+
+.docs-search .form-control:focus {
+ border-color: {{ .Get "primary" }};
+ box-shadow: 0 0 0 3px {{ .Get "primary_light" }};
+}
+
+/* Docs sidebar. */
+
+.docs-sidebar {
+ order: 0;
+ border-bottom: 1px solid rgba(0, 0, 0, .1)
+}
+
+@media (min-width:768px) {
+ .docs-sidebar {
+ border-right: 1px solid rgba(0, 0, 0, .1)
+ }
+ @supports ((position:-webkit-sticky) or (position:sticky)) {
+ .docs-sidebar {
+ position: -webkit-sticky;
+ position: sticky;
+ top: 71px;
+ z-index: 1000;
+ height: calc(100vh - 71px)
+ }
+ }
+}
+
+@media (min-width:1200px) {
+ .docs-sidebar {
+ flex: 0 1 320px
+ }
+}
+
+/* Docs sidebar li>a. */
+
+.docs-sidebar .nav>li>a {
+ display: block;
+ padding: .25rem 1.5rem;
+ font-size: 90%;
+ color: rgba(0, 0, 0, .65);
+}
+
+.docs-sidebar .nav>li>a:hover {
+ color: rgba(0, 0, 0, .85);
+ text-decoration: none;
+ background-color: transparent;
+}
+
+.docs-sidebar .docs-toc-item.active a,
+.docs-sidebar .nav>.active:hover>a,
+.docs-sidebar .nav>.active>a {
+ font-weight: bold;
+ color: {{ .Get "primary" }};
+ background-color: transparent;
+}
+
+/* Docs links. */
+
+.docs-links {
+ padding-top: 1rem;
+ padding-bottom: 1rem;
+ margin-right: -15px;
+ margin-left: -15px;
+}
+
+@media (min-width:768px) {
+ @supports (position: sticky) {
+ .docs-links {
+ max-height: calc(100vh - 5rem - 71px);
+ overflow-y: auto;
+ }
+ }
+}
+
+@media (min-width:768px) {
+ .docs-links {
+ display: block!important;
+ }
+}
+
+/* Docs TOC. */
+
+.docs-toc {
+ order: 2;
+ padding-top: 1.5rem;
+ padding-bottom: 1.5rem;
+ font-size: .875rem
+}
+
+@supports ((position:-webkit-sticky) or (position:sticky)) {
+ .docs-toc {
+ position: -webkit-sticky;
+ position: sticky;
+ top: 4rem;
+ height: calc(100vh - 4rem);
+ overflow-y: auto
+ }
+}
+
+/* Docs TOC item links. */
+
+.docs-toc-link {
+ display: block;
+ padding: .25rem 1.5rem;
+ font-weight: bold;
+ color: rgba(0, 0, 0, .65);
+}
+
+.docs-toc-link:hover {
+ color: rgba(0, 0, 0, .85);
+ text-decoration: none;
+}
+
+.docs-toc-item.active {
+ margin-bottom: 1rem;
+}
+
+.docs-toc-item.active:not(:first-child) {
+ margin-top: 1rem;
+}
+
+.docs-toc-item.active>.docs-toc-link {
+ color: rgba(0, 0, 0, .85);
+}
+
+.docs-toc-item.active>.docs-toc-link:hover {
+ background-color: transparent;
+}
+
+.docs-toc-item.active>.docs-sidenav {
+ display: block;
+}
+
+/* Docs TOC nav. */
+
+#TableOfContents {
+ padding-left: 0;
+ border-left: 1px solid #eee;
+}
+
+#TableOfContents ul {
+ padding-left: 1rem;
+}
+
+#TableOfContents ul ul {
+ display: none;
+}
+
+#TableOfContents li {
+ display: block;
+}
+
+#TableOfContents li a {
+ display: block;
+ padding: .125rem 1.5rem;
+ color: #99979c;
+}
+
+#TableOfContents li a:hover {
+ color: {{ .Get "primary" }};
+ text-decoration: none;
+}
+
+/* Docs achnorjs links. */
+
+.anchorjs-link {
+ font-weight: 400;
+ color: {{ .Get "primary_dark" }};
+ transition: color .16s linear;
+}
+
+.anchorjs-link:hover {
+ color: {{ .Get "primary" }};
+ text-decoration: none;
+}
+
/*************************************************
* Dark themed components
**************************************************/
-body.dark {
+body.dark,
+.dark .docs-toc-link,
+.dark .docs-sidebar .nav > li:not(.active) > a,
+.dark .modal button.close,
+.dark input,
+.dark .form-control:focus {
color: rgb(248, 248, 242);
}
-.dark input {
- color: rgb(248, 248, 242);
-}
-
-.dark .modal button.close {
- color: rgb(248, 248, 242);
+.dark .form-control:focus {
+ background-color: rgb(68, 71, 90);
+ border-color: {{ .Get "primary" }};
+ box-shadow: 0 0 0 .2rem {{ .Get "primary_dark" }};
}
.dark h1,
diff --git a/layouts/partials/docs_layout.html b/layouts/partials/docs_layout.html
new file mode 100644
index 00000000..9fff5a7d
--- /dev/null
+++ b/layouts/partials/docs_layout.html
@@ -0,0 +1,47 @@
+{{ partial "header.html" . }}
+{{ partial "navbar.html" . }}
+{{ $current_page := . }}
+
+
+
+
+
+ {{ if .Params.toc }}
+
+ {{ .TableOfContents }}
+
+ {{ end }}
+
+
+
+
+
+
+
+ {{ partial "header_image.html" . }}
+
+
+
{{ .Title }}
+
+
+ {{ .Content }}
+
+
+ {{ partial "tags.html" . }}
+
+
+
+ {{ i18n "last_updated" }} {{ $.Lastmod.Format $.Site.Params.date_format }}
+
+
+
+
+ {{ partial "footer_section.html" . }}
+
+
+
+
+
+{{ partial "footer.html" . }}
diff --git a/layouts/partials/docs_sidebar.html b/layouts/partials/docs_sidebar.html
new file mode 100644
index 00000000..4948dbe3
--- /dev/null
+++ b/layouts/partials/docs_sidebar.html
@@ -0,0 +1,26 @@
+{{ $current_page := . }}
+
+{{ if eq $.Site.Params.search.engine 1 }}
+
+{{ end }}
+
+
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index c89dfb58..447188c7 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -69,6 +69,7 @@
const search_index_filename = {{ "/index.json" | relURL }};
const i18n = {
'placeholder': {{ i18n "search_placeholder" }},
+ 'results': {{ i18n "search_results" }},
'no_results': {{ i18n "search_no_results" }}
};
const content_type = {
@@ -80,6 +81,14 @@
{{ end }}
+ {{/* Load hash anchors for documentation pages. */}}
+ {{ if eq .Type "docs" }}
+ {{ printf "" (printf $js.anchor.url $js.anchor.version) $js.anchor.sri | safeHTML }}
+
+ {{ end }}
+
{{/* Fuse search engine. */}}
{{ if eq .Site.Params.search.engine 1 }}
{{ printf "" (printf $js.fuse.url $js.fuse.version) $js.fuse.sri | safeHTML }}
@@ -160,5 +169,33 @@
{{ end }}
+ {{ if eq $.Site.Params.search.engine 1 }}
+ {{/* Fuse search result template. */}}
+
+ {{ else if eq $.Site.Params.search.engine 2 }}
+ {{/* Algolia search result template. */}}
+
+ {{ end }}
+