mirror of
https://github.com/gcushen/hugo-academic.git
synced 2025-07-26 19:15:16 +02:00
feat: add support for Book-based homepage
Enables the Book layout to be used directly at the root of the site.
This commit is contained in:
parent
886eb23663
commit
6d04dbe81a
4 changed files with 36 additions and 12 deletions
|
@ -108,6 +108,7 @@
|
|||
}
|
||||
|
||||
.docs-sidebar .docs-toc-item.active a,
|
||||
.docs-sidebar .docs-toc-item a.active, // Book layout sidebar links
|
||||
.docs-sidebar .nav>.active:hover>a,
|
||||
.docs-sidebar .nav>.active>a {
|
||||
font-weight: bold;
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
{{ end }}
|
||||
|
||||
{{/* Generate homepage. */}}
|
||||
{{ partial "widget_page.html" . }}
|
||||
{{ if eq .Type "book" }}
|
||||
{{ partial "book_layout.html" . }}
|
||||
{{ else }}
|
||||
{{ partial "widget_page.html" . }}
|
||||
{{ end }}
|
||||
|
||||
{{- end -}}
|
||||
|
|
|
@ -2,12 +2,15 @@
|
|||
|
||||
{{- $first := false -}}
|
||||
{{- $current_node := .current_node -}}
|
||||
{{- $is_root := .is_root -}}
|
||||
{{- $order_by := .order_by -}}
|
||||
{{ $icon := "" }}
|
||||
|
||||
{{ with .sect }}
|
||||
{{ if .IsSection}}
|
||||
{{- $first = eq $current_node.FirstSection . -}}
|
||||
{{ if not $is_root }}
|
||||
{{- $first = eq $current_node.FirstSection . -}}
|
||||
{{ end }}
|
||||
|
||||
{{- safeHTML $current_node.FirstSection.Params.pre_nav -}}
|
||||
|
||||
|
|
|
@ -10,19 +10,35 @@
|
|||
|
||||
<nav class="collapse docs-links" id="docs-nav">
|
||||
{{ $current_node := . }}
|
||||
{{ $menu_name := (path.Base (path.Split .FirstSection).Dir) }}
|
||||
{{ $menu_name := "" }}
|
||||
{{ $order_by := cond (eq $menu_name "updates") "title_desc" site.Params.books.order_by }}
|
||||
|
||||
{{ $query := "" }}
|
||||
{{- if eq $order_by "title" -}}
|
||||
{{- $query = where .Site.Home.Sections.ByTitle "Section" $menu_name -}}
|
||||
{{- else if eq $order_by "title_desc" -}}
|
||||
{{- $query = where .Site.Home.Sections.ByTitle.Reverse "Section" $menu_name -}}
|
||||
{{- else -}}
|
||||
{{- $query = where .Site.Home.Sections.ByWeight "Section" $menu_name -}}
|
||||
{{- end}}
|
||||
{{ $root_page := .GetPage "/_index.md" }}
|
||||
{{ $is_root := false}}
|
||||
{{ if $root_page | and (eq $root_page.Type "book") }}
|
||||
{{ $is_root = true}}
|
||||
<ul class="nav docs-sidenav">
|
||||
<li class="{{ if .IsHome }}active{{ end }}"><a href="{{ $root_page.RelPermalink }}">{{$root_page.Title}}</a></li>
|
||||
</ul>
|
||||
{{- if eq $order_by "title" -}}
|
||||
{{- $query = .Site.Home.Sections.ByTitle -}}
|
||||
{{- else if eq $order_by "title_desc" -}}
|
||||
{{- $query = .Site.Home.Sections.ByTitle.Reverse -}}
|
||||
{{- else -}}
|
||||
{{- $query = .Site.Home.Sections.ByWeight -}}
|
||||
{{- end}}
|
||||
{{else}}
|
||||
{{ $menu_name = (path.Base (path.Split .FirstSection).Dir) }}
|
||||
{{- if eq $order_by "title" -}}
|
||||
{{- $query = where .Site.Home.Sections.ByTitle "Section" $menu_name -}}
|
||||
{{- else if eq $order_by "title_desc" -}}
|
||||
{{- $query = where .Site.Home.Sections.ByTitle.Reverse "Section" $menu_name -}}
|
||||
{{- else -}}
|
||||
{{- $query = where .Site.Home.Sections.ByWeight "Section" $menu_name -}}
|
||||
{{- end}}
|
||||
{{end}}
|
||||
|
||||
{{- range $query -}}
|
||||
{{ template "book-menu" dict "sect" . "current_node" $current_node "order_by" $order_by }}
|
||||
{{ template "book-menu" dict "sect" . "current_node" $current_node "order_by" $order_by "is_root" $is_root }}
|
||||
{{- end -}}
|
||||
</nav>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue