mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
feat: add children shortcode
This commit is contained in:
parent
951e8fb40e
commit
3e61961bfa
4 changed files with 146 additions and 1 deletions
|
@ -1,9 +1,9 @@
|
|||
- récriture doc -> TODO
|
||||
- créer une section Showcase
|
||||
- créer des jolis thèmes de base (avec des noms) -> TODO
|
||||
- ajouter les attachments -> TODO
|
||||
- ajouter les childs -> TODO
|
||||
|
||||
- ajouter les attachments -> OK
|
||||
- refaire la possibilité d'overrider le style/script/etc -> OK
|
||||
- sticky bar -> OK
|
||||
- ajouter Travis pour tester le thème quotidiennement avec les nouvelles versions de Hugo -> OK
|
||||
|
|
|
@ -4,6 +4,26 @@ title: Pages
|
|||
weight: 5
|
||||
---
|
||||
|
||||
{{%/* children */%}}
|
||||
|
||||
{{%children %}}
|
||||
|
||||
{{%/* children description="true" */%}}
|
||||
|
||||
{{%children description="true" %}}
|
||||
|
||||
{{%/* children depth="3" showhidden="true" */%}}
|
||||
|
||||
{{% children depth="3" showhidden="true" %}}
|
||||
|
||||
{{%/* children style="h2" depth="3" description="true" */%}}
|
||||
|
||||
{{% children style="h2" depth="3" description="true" %}}
|
||||
|
||||
{{%/* children style="div" depth="999" */%}}
|
||||
|
||||
{{% children style="div" depth="999" %}}
|
||||
|
||||
In **Hugo**, pages are the core of your site. Once it is configure, pages are definitely the added value to your documentation site.
|
||||
|
||||
## Folders
|
||||
|
|
96
layouts/shortcodes/children.html
Normal file
96
layouts/shortcodes/children.html
Normal file
|
@ -0,0 +1,96 @@
|
|||
{{ $showhidden := .Get "showhidden"}}
|
||||
{{ $style := .Get "style" | default "li" }}
|
||||
{{ $depth := .Get "depth" | default 1 }}
|
||||
{{ $withDescription := .Get "description" | default false }}
|
||||
{{ $sortTerm := .Get "sort" | default "Weight" }}
|
||||
|
||||
|
||||
<ul class="children children-{{$style}}">
|
||||
{{ .Scratch.Set "pages" .Page.Pages }}
|
||||
{{ if .Page.Sections}}
|
||||
{{ .Scratch.Set "pages" (.Page.Pages | union .Page.Sections) }}
|
||||
{{end}}
|
||||
{{ $pages := (.Scratch.Get "pages") }}
|
||||
|
||||
{{if eq $sortTerm "Weight"}}
|
||||
{{template "childs" dict "menu" $pages.ByWeight "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{else if eq $sortTerm "Name"}}
|
||||
{{template "childs" dict "menu" $pages.ByTitle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{else if eq $sortTerm "PublishDate"}}
|
||||
{{template "childs" dict "menu" $pages.ByPublishDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{else if eq $sortTerm "Date"}}
|
||||
{{template "childs" dict "menu" $pages.ByDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{else if eq $sortTerm "Length"}}
|
||||
{{template "childs" dict "menu" $pages.ByLength "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{else}}
|
||||
{{template "childs" dict "menu" $pages "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
{{.Inner|safeHTML}}
|
||||
|
||||
{{ define "childs" }}
|
||||
{{ range .menu }}
|
||||
{{ if and .Params.hidden (not $.showhidden) }}
|
||||
{{else}}
|
||||
|
||||
|
||||
{{if hasPrefix $.style "h"}}
|
||||
{{$num := sub ( int (trim $.style "h") ) 1 }}
|
||||
{{$numn := add $num $.count }}
|
||||
|
||||
{{(printf "<h%d>" $numn)|safeHTML}}
|
||||
<a href="{{.URL}}" >{{ .Title }}</a>
|
||||
{{(printf "</h%d>" $numn)|safeHTML}}
|
||||
|
||||
{{else}}
|
||||
{{(printf "<%s>" $.style)|safeHTML}}
|
||||
<a href="{{.URL}}" >{{ .Title }}</a>
|
||||
{{(printf "</%s>" $.style)|safeHTML}}
|
||||
{{end}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{{if $.description}}
|
||||
{{if .Description}}
|
||||
<p>{{.Description}}</p>
|
||||
{{else}}
|
||||
<p>{{.Summary}}</p>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
|
||||
|
||||
{{ if lt $.count $.depth}}
|
||||
{{if eq $.style "li"}}
|
||||
<ul>
|
||||
{{end}}
|
||||
{{ .Scratch.Set "pages" .Pages }}
|
||||
{{ if .Sections}}
|
||||
{{ .Scratch.Set "pages" (.Pages | union .Sections) }}
|
||||
{{end}}
|
||||
{{ $pages := (.Scratch.Get "pages") }}
|
||||
|
||||
{{if eq $.sortTerm "Weight"}}
|
||||
{{template "childs" dict "menu" $pages.ByWeight "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{else if eq $.sortTerm "Name"}}
|
||||
{{template "childs" dict "menu" $pages.ByTitle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{else if eq $.sortTerm "PublishDate"}}
|
||||
{{template "childs" dict "menu" $pages.ByPublishDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{else if eq $.sortTerm "Date"}}
|
||||
{{template "childs" dict "menu" $pages.ByDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{else if eq $.sortTerm "Length"}}
|
||||
{{template "childs" dict "menu" $pages.ByLength "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{else}}
|
||||
{{template "childs" dict "menu" $pages "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{end}}
|
||||
{{if eq $.style "li"}}
|
||||
</ul>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
|
@ -530,6 +530,8 @@ div.notices.tip p:first-child:after {
|
|||
content: 'Tip';
|
||||
}
|
||||
|
||||
/* attachments shortcode */
|
||||
|
||||
section.attachments {
|
||||
margin: 2rem 0;
|
||||
position: relative;
|
||||
|
@ -588,6 +590,33 @@ section.attachments.note .attachments-files {
|
|||
background: #E7F2FA;
|
||||
}
|
||||
|
||||
/* Children shortcode */
|
||||
|
||||
/* Children shortcode */
|
||||
.children p {
|
||||
font-size: small;
|
||||
margin-top: 0px;
|
||||
padding-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
.children-li p {
|
||||
font-size: small;
|
||||
font-style: italic;
|
||||
|
||||
}
|
||||
.children-h2 p, .children-h3 p {
|
||||
font-size: small;
|
||||
margin-top: 0px;
|
||||
padding-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
.children h3,.children h2 {
|
||||
margin-bottom: 0px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
code, kbd, pre, samp {
|
||||
font-family: "Consolas", menlo, monospace;
|
||||
font-size: 92%;
|
||||
|
|
Loading…
Reference in a new issue