Compare commits

...

1 commit

Author SHA1 Message Date
Alex Shpak
7b5d299b7b Rewrite prev-next with enw lang. selector 2021-08-30 14:13:46 +02:00
8 changed files with 68 additions and 17 deletions

View file

@ -250,10 +250,20 @@ body[dir="rtl"] .book-menu {
padding-top: $padding-16;
font-size: $font-size-14;
a {
margin: $padding-8 0;
}
img {
height: 1em;
width: 1em;
margin-inline-end: $padding-8;
&:first-child {
margin-inline-end: $padding-8;
}
&:last-child {
margin-inline-start: $padding-8;
}
}
}

View file

@ -1 +1 @@
{"Target":"book.min.8599444fcc48ee6b435b5b62c955ab7d914fa1e2a453df90c4b97cc9769665d1.css","MediaType":"text/css","Data":{"Integrity":"sha256-hZlET8xI7mtDW1tiyVWrfZFPoeKkU9+QxLl8yXaWZdE="}}
{"Target":"book.min.ad694c0f1601cd801d432bdb4a6abae57aa202e0cec7e44e2f6ab46fbe7b628c.css","MediaType":"text/css","Data":{"Integrity":"sha256-rWlMDxYBzYAdQyvbSmq65XqiAuDOx+ROL2q0b757Yow="}}

View file

@ -1,27 +1,25 @@
<div class="flex flex-wrap justify-between">
{{ if and .GitInfo .Site.Params.BookRepo }}
<div>
{{- $date := partial "docs/date" (dict "Date" .GitInfo.AuthorDate.Local "Format" .Site.Params.BookDateFormat) -}}
{{- $commitPath := default "commit" .Site.Params.BookCommitPath -}}
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ $commitPath }}/{{ .GitInfo.Hash }}" title='{{ i18n "Last modified by" }} {{ .GitInfo.AuthorName }} | {{ $date }}' target="_blank" rel="noopener">
<img src="{{ "svg/calendar.svg" | relURL }}" class="book-icon" alt="Calendar" />
<span>{{ $date }}</span>
</a>
</div>
{{- $date := partial "docs/date" (dict "Date" .GitInfo.AuthorDate.Local "Format" .Site.Params.BookDateFormat) -}}
{{- $commitPath := default "commit" .Site.Params.BookCommitPath -}}
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ $commitPath }}/{{ .GitInfo.Hash }}" title='{{ i18n "Last modified by" }} {{ .GitInfo.AuthorName }} | {{ $date }}' target="_blank" rel="noopener">
<img src="{{ "svg/calendar.svg" | relURL }}" class="book-icon" alt="Calendar" />
<span>{{ $date }}</span>
</a>
{{ end }}
{{ if and .File .Site.Params.BookRepo .Site.Params.BookEditPath }}
<div>
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}/{{ .Site.Params.contentDir | default "content" }}/{{ replace .File.Path "\\" "/" }}" target="_blank" rel="noopener">
<img src="{{ "svg/edit.svg" | relURL }}" class="book-icon" alt="Edit" />
<span>{{ i18n "Edit this page" }}</span>
</a>
</div>
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}/{{ .Site.Params.contentDir | default "content" }}/{{ replace .File.Path "\\" "/" }}" target="_blank" rel="noopener">
<img src="{{ "svg/edit.svg" | relURL }}" class="book-icon" alt="Edit" />
<span>{{ i18n "Edit this page" }}</span>
</a>
{{ end }}
</div>
{{ partial "docs/prev-next" . }}
{{ $script := resources.Get "clipboard.js" | resources.Minify }}
{{ with $script.Content }}
<script>{{ . | safeJS }}</script>

View file

@ -0,0 +1,14 @@
{{ $scratch := newScratch }}
{{ template "recurse" (dict "Scratch" $scratch "Sections" .) }}
{{ define "recurse" }}
{{ range .Sections }}
{{ if and .Content (not .Params.BookHidden) }}
{{ $.Scratch.Add "BookPages" (slice .) }}
{{ end }}
{{ if .IsSection }}
{{ template "recurse" (dict "Scratch" $.Scratch "Sections" .Pages) }}
{{ end }}
{{ end }}
{{ end }}
{{ return $scratch.Get "BookPages" }}

View file

@ -0,0 +1,27 @@
{{ $bookSection := default "docs" .Site.Params.BookSection }}
{{ if eq $bookSection "*" }}
{{ $bookSection = "/" }}{{/* Backward compatibility */}}
{{ end }}
{{ with .Site.GetPage $bookSection }}
{{ $pages := partialCached "docs/prev-next-cache" .Pages }}
{{ $prev := $pages.Next $ }}
{{ $next := $pages.Prev $ }}
{{- if or $prev $next }}
<div class="flex flex-wrap justify-between">
{{ with $prev }}
<a href="{{ .RelPermalink }}" class="flex align-center float-left book-icon">
<img src="{{ "svg/backward.svg" | relURL }}" alt="Previous" title="{{ partial "docs/title" . }}" />
<span>{{ partial "docs/title" . }}</span>
</a>
{{ end }}
{{ with $next }}
<a href="{{ .RelPermalink }}" class="flex align-center float-right book-icon">
<span>{{ partial "docs/title" . }}</span>
<img src="{{ "svg/forward.svg" | relURL }}" alt="Next" title="{{ partial "docs/title" . }}" />
</a>
{{ end }}
</div>
{{ end -}}
{{ end }}

1
static/svg/backward.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>

After

Width:  |  Height:  |  Size: 198 B

1
static/svg/forward.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"/></svg>

After

Width:  |  Height:  |  Size: 195 B