Skip to content

Commit 5f4f41f

Browse files
authored
fix: Update layout for header and topnav (#26)
Signed-off-by: Artem Kladov <artem.kladov@flant.com>
1 parent ce70a0d commit 5f4f41f

File tree

10 files changed

+76
-20
lines changed

10 files changed

+76
-20
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ The documentation content is written in Markdown with some custom shortcodes.
3636

3737
### Page parameters (front matter)
3838

39+
#### Search index for documentation section
40+
41+
To generate `documentation/search.json` for offline search, add `search` to the outputs of the `documentation/_index.*` pages:
42+
43+
```yaml
44+
---
45+
title: Deckhouse <PRODUCT_NAME>
46+
outputs:
47+
- HTML
48+
- search
49+
---
50+
```
51+
3952
#### Related links
4053

4154
```yaml

hugo.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
outputFormats:
2+
search:
3+
mediaType: application/json
4+
baseName: search
5+
isPlainText: true
6+
notAlternative: true

i18n/en.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ platform: platform
7878
required_value_sentence: Required value
7979
related_additional_resources: Additional resources
8080
reset_filter: reset filter
81-
search_context_dkpdocs_and_modules: The search is performed throughout DKP documentation and modules.
82-
search_context_modules: The search is performed throughout modules, excluding the DKP documentation.
83-
search_context_only_product_docs: The search is performed throughout the product documentation, excluding modules.
81+
search_context_dkpdocs_and_modules: The search is performed across all documentation of the current product.
8482
search_placeholder_text: Search...
8583
section_list_title: Section contents
8684
show_more: Show more

i18n/ru.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ platform: платформа
7878
required_value_sentence: Обязательный параметр
7979
related_additional_resources: Дополнительные ресурсы
8080
reset_filter: Сбросить фильтр
81-
search_context_dkpdocs_and_modules: Поиск выполняется по всей документации DKP и модулям.
82-
search_context_modules: Поиск выполняется по всем модулям, не включая документацию DKP.
83-
search_context_only_product_docs: Поиск выполняется по всей документации продукта, не включая модули.
81+
search_context_message: Поиск выполняется по всей документации текущего продукта.
8482
search_placeholder_text: Поиск...
8583
section_list_title: Содержание раздела
8684
show_more: Показать ещё

layouts/_default/list.search.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- $documents := slice -}}
2+
{{- range .RegularPagesRecursive -}}
3+
{{- if and (ne .Params.hidden true) (ne .Params.noindex true) -}}
4+
{{- $bc := slice -}}
5+
{{- $skipTopSection := true -}}
6+
{{- range .Ancestors.Reverse -}}
7+
{{- if .IsHome -}}
8+
{{- continue -}}
9+
{{- end -}}
10+
{{- if $skipTopSection -}}
11+
{{- $skipTopSection = false -}}
12+
{{- continue -}}
13+
{{- end -}}
14+
{{- $bc = $bc | append .LinkTitle -}}
15+
{{- end -}}
16+
{{- $documents = $documents | append (dict
17+
"title" .Title
18+
"url" .RelPermalink
19+
"keywords" .Params.keywords
20+
"bc" $bc
21+
"content" (.Plain | replaceRE "\\s+" " " | strings.TrimSpace)
22+
) -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- dict "documents" $documents "parameters" (slice) | jsonify -}}

layouts/_partials/sidebar.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- $currentPage := . -}}
2-
2+
<!--noindex-->
33
<div class="sidebar__wrapper-inner">
44
<nav class="sidebar__container">
55
<ul class="sidebar" id="mysidebar">
@@ -15,6 +15,7 @@
1515
</ul>
1616
</nav>
1717
</div>
18+
<!--/noindex-->
1819

1920
{{/* --- subpages --- */}}
2021
{{- define "subpages" }}

layouts/_partials/toc.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
$(document).ready(function () {
44
// Handler for .ready() called.
55

6+
function getHeaderHeight() {
7+
const header = $('header');
8+
return header.outerHeight(true);
9+
}
10+
11+
const headerHeight = getHeaderHeight();
12+
const $sidebar = $('.sidebar__wrapper-inner');
13+
$sidebar.css("top", headerHeight);
14+
const $navigationContainer = $('.navigation__container');
15+
$navigationContainer.css("top", headerHeight);
16+
617
const $toc = $('#toc-sidebar');
718

819
$toc.toc({

layouts/baseof.html

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,22 @@
1515

1616
<div class="container">
1717

18-
<div class="breadcrumbs-container">
19-
<div class="breadcrumbs__left">
20-
<ol class="breadcrumbs">
21-
<!-- <li class="breadcrumbs__item">{{ T "modules_documentation" | humanize }}</li>-->
22-
</ol>
18+
<!--noindex-->
19+
<div class="navigation__container">
20+
<div class="navigation__container--versions"></div>
21+
<div class="breadcrumbs__container">
22+
<ol class="breadcrumbs">
23+
{{- partial "breadcrumbs" . }}
24+
</ol>
2325
</div>
24-
<div class="breadcrumbs__right">
25-
<ol class="breadcrumbs">
26-
{{- partial "breadcrumbs" . }}
27-
</ol>
28-
</div>
29-
{{ if .Params.search_enabled }}
26+
{{ if .Site.Params.offlineSearch }}
3027
<!--start search-->
3128
<div class="searchV3">
3229
<div class="container">
3330
<div class="input-wrapper">
3431
<input type="text" id="search-input" placeholder='{{ T "search_placeholder_text" }}' class="input"
35-
data-search-index-path="/search.json:1.0"
36-
data-search-context='{{ T "search_context_only_product_docs" }}'
32+
data-search-index-path='{{ strings.TrimSuffix "/" (urls.Parse site.BaseURL).Path }}/documentation/search.json:1.0'
33+
data-search-context='{{ T "search_context_message" }}'
3734
>
3835
<div id="search-results" class="results" style="display: none"></div>
3936
</div>
@@ -46,6 +43,7 @@
4643
<!--end loading search JS-->
4744
{{ end }}
4845
</div>
46+
<!--/noindex-->
4947

5048
<div class="layout-sidebar">
5149
<div class="layout-sidebar__sidebar">
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
title: Deckhouse <PRODUCT_NAME>
33
weight: 1
4+
outputs:
5+
- HTML
6+
- search
47
---
58

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
title: Deckhouse <PRODUCT_NAME>
33
weight: 1
4+
outputs:
5+
- HTML
6+
- search
47
---
58

0 commit comments

Comments
 (0)