From 5ffc5a3ef2d7e2ec361dd98b9dd759204211ccba Mon Sep 17 00:00:00 2001 From: aniket866 Date: Sat, 1 Aug 2026 00:39:42 +0530 Subject: [PATCH 1/2] fixing-comma-handling-delimeter Signed-off-by: aniket866 --- themes/microcks/layouts/_default/index.json | 64 +++++++++---------- .../microcks/layouts/documentation/index.json | 64 +++++++++---------- 2 files changed, 60 insertions(+), 68 deletions(-) diff --git a/themes/microcks/layouts/_default/index.json b/themes/microcks/layouts/_default/index.json index 0f428763..54b754ce 100644 --- a/themes/microcks/layouts/_default/index.json +++ b/themes/microcks/layouts/_default/index.json @@ -1,36 +1,32 @@ -{{- $len := sub (len (.Pages.GroupBy "Section")) 1 -}} -[{{- range $item, $el := .Pages.GroupBy "Section" -}} -{{- range $i, $e := .Pages -}} -{{- if and (not .Params.ignoreSearch) (ne $e.Type "json") -}} - { - "section": "", - "url": "{{ $e.Permalink }}", - "title": "{{ with $e.Params.bannertext }}{{htmlEscape .}}{{else}}{{htmlEscape $e.Title}}{{end}}", - "description": "{{ htmlEscape .Description}}", - "searchKeyword": "{{ htmlEscape .Params.searchKeyword}}", - "content": {{$e.Plain | jsonify}} - }{{- if eq $item $len -}}{{- else -}},{{- end -}} -{{- end -}} - -{{- if .Section -}} -{{- $section := (where site.Pages "Section" .Section) | intersect (where site.Pages ".Title" "!=" .Title) -}} -{{- $sectionLen := len (where site.Pages "Section" .Section) -}} -{{- $sectionLenTotal := sub $sectionLen 2 -}} - -{{- range $index, $page := $section -}} -{{- if and (not .Params.ignoreSearch) (ne $page.Type "json") -}} - { - "section": "{{$page.Section | humanize}}", - "url": "{{ $page.Permalink }}", - "title": "{{ with $page.Params.bannertext }}{{htmlEscape .}}{{else}}{{htmlEscape $page.Title}}{{end}}", - "description": "{{ htmlEscape .Description}}", - "searchKeyword": "{{ htmlEscape .Params.searchKeyword}}", - "content": {{$page.Plain | jsonify}} - }{{- if eq $item $len -}}{{- if ne $index $sectionLenTotal -}},{{- end -}}{{- else -}},{{- end -}} -{{- end -}} -{{- end -}} - -{{- end -}} +{{- $.Scratch.Delete "search_index" -}} +{{- range $item, $el := .Pages.GroupBy "Section" -}} + {{- range $i, $e := .Pages -}} + {{- if and (not $e.Params.ignoreSearch) (ne $e.Type "json") -}} + {{- $title := $e.Title -}} + {{- if $e.Params.bannertext -}} + {{- $title = $e.Params.bannertext -}} + {{- end -}} + {{- $entry := dict "section" "" "url" $e.Permalink "title" (htmlEscape $title) "description" (htmlEscape $e.Description) "searchKeyword" (htmlEscape $e.Params.searchKeyword) "content" $e.Plain -}} + {{- $.Scratch.Add "search_index" (slice $entry) -}} + {{- end -}} + {{- end -}} + {{- if .Section -}} + {{- $section := (where site.Pages "Section" .Section) | intersect (where site.Pages ".Title" "!=" .Title) -}} + {{- range $index, $page := $section -}} + {{- if and (not $page.Params.ignoreSearch) (ne $page.Type "json") -}} + {{- $title := $page.Title -}} + {{- if $page.Params.bannertext -}} + {{- $title = $page.Params.bannertext -}} + {{- end -}} + {{- $entry := dict "section" ($page.Section | humanize) "url" $page.Permalink "title" (htmlEscape $title) "description" (htmlEscape $page.Description) "searchKeyword" (htmlEscape $page.Params.searchKeyword) "content" $page.Plain -}} + {{- $.Scratch.Add "search_index" (slice $entry) -}} + {{- end -}} + {{- end -}} + {{- end -}} {{- end -}} -{{- end -}}] \ No newline at end of file +{{- with $.Scratch.Get "search_index" -}} + {{- . | jsonify -}} +{{- else -}} + [] +{{- end -}} \ No newline at end of file diff --git a/themes/microcks/layouts/documentation/index.json b/themes/microcks/layouts/documentation/index.json index 25fe5c79..54b754ce 100644 --- a/themes/microcks/layouts/documentation/index.json +++ b/themes/microcks/layouts/documentation/index.json @@ -1,36 +1,32 @@ -{{- $len := sub (len (.Pages.GroupBy "Section")) 1 -}} -[{{- range $item, $el := .Pages.GroupBy "Section" -}} -{{- range $i, $e := .Pages -}} -{{- if and (not .Params.ignoreSearch) (ne $e.Type "json") -}} - { - "section": "", - "url": "{{ $e.Permalink }}", - "title": "{{ with $e.Params.bannertext }}{{htmlEscape .}}{{else}}{{htmlEscape $e.Title}}{{end}}", - "description": "{{ htmlEscape .Description}}", - "searchKeyword": "{{ htmlEscape .Params.searchKeyword}}", - "content": {{$e.Plain | jsonify}} - }, -{{- end -}} - -{{- if .Section -}} -{{- $section := (where site.Pages "Section" .Section) | intersect (where site.Pages ".Title" "!=" .Title) -}} -{{- $sectionLen := len (where site.Pages "Section" .Section) -}} -{{- $sectionLenTotal := sub $sectionLen 2 -}} - -{{- range $index, $page := $section -}} -{{- if and (not .Params.ignoreSearch) (ne $page.Type "json") -}} - { - "section": "{{$page.Section | humanize}}", - "url": "{{ $page.Permalink }}", - "title": "{{ with $page.Params.bannertext }}{{htmlEscape .}}{{else}}{{htmlEscape $page.Title}}{{end}}", - "description": "{{ htmlEscape .Description}}", - "searchKeyword": "{{ htmlEscape .Params.searchKeyword}}", - "content": {{$page.Plain | jsonify}} - }{{- if eq $item $len -}}{{- if ne $index $sectionLenTotal -}},{{- end -}}{{- else -}},{{- end -}} -{{- end -}} -{{- end -}} - -{{- end -}} +{{- $.Scratch.Delete "search_index" -}} +{{- range $item, $el := .Pages.GroupBy "Section" -}} + {{- range $i, $e := .Pages -}} + {{- if and (not $e.Params.ignoreSearch) (ne $e.Type "json") -}} + {{- $title := $e.Title -}} + {{- if $e.Params.bannertext -}} + {{- $title = $e.Params.bannertext -}} + {{- end -}} + {{- $entry := dict "section" "" "url" $e.Permalink "title" (htmlEscape $title) "description" (htmlEscape $e.Description) "searchKeyword" (htmlEscape $e.Params.searchKeyword) "content" $e.Plain -}} + {{- $.Scratch.Add "search_index" (slice $entry) -}} + {{- end -}} + {{- end -}} + {{- if .Section -}} + {{- $section := (where site.Pages "Section" .Section) | intersect (where site.Pages ".Title" "!=" .Title) -}} + {{- range $index, $page := $section -}} + {{- if and (not $page.Params.ignoreSearch) (ne $page.Type "json") -}} + {{- $title := $page.Title -}} + {{- if $page.Params.bannertext -}} + {{- $title = $page.Params.bannertext -}} + {{- end -}} + {{- $entry := dict "section" ($page.Section | humanize) "url" $page.Permalink "title" (htmlEscape $title) "description" (htmlEscape $page.Description) "searchKeyword" (htmlEscape $page.Params.searchKeyword) "content" $page.Plain -}} + {{- $.Scratch.Add "search_index" (slice $entry) -}} + {{- end -}} + {{- end -}} + {{- end -}} {{- end -}} -{{- end -}}] \ No newline at end of file +{{- with $.Scratch.Get "search_index" -}} + {{- . | jsonify -}} +{{- else -}} + [] +{{- end -}} \ No newline at end of file From eb70b37a5c021a5f9e7db68d7ae89d86366c71d4 Mon Sep 17 00:00:00 2001 From: aniket866 Date: Sat, 1 Aug 2026 01:23:40 +0530 Subject: [PATCH 2/2] fixing-comma-handling Signed-off-by: aniket866 --- themes/microcks/layouts/_default/index.json | 20 +++++++++---------- .../microcks/layouts/documentation/index.json | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/themes/microcks/layouts/_default/index.json b/themes/microcks/layouts/_default/index.json index 54b754ce..787df827 100644 --- a/themes/microcks/layouts/_default/index.json +++ b/themes/microcks/layouts/_default/index.json @@ -10,18 +10,18 @@ {{- $.Scratch.Add "search_index" (slice $entry) -}} {{- end -}} {{- end -}} +{{- end -}} - {{- if .Section -}} - {{- $section := (where site.Pages "Section" .Section) | intersect (where site.Pages ".Title" "!=" .Title) -}} - {{- range $index, $page := $section -}} - {{- if and (not $page.Params.ignoreSearch) (ne $page.Type "json") -}} - {{- $title := $page.Title -}} - {{- if $page.Params.bannertext -}} - {{- $title = $page.Params.bannertext -}} - {{- end -}} - {{- $entry := dict "section" ($page.Section | humanize) "url" $page.Permalink "title" (htmlEscape $title) "description" (htmlEscape $page.Description) "searchKeyword" (htmlEscape $page.Params.searchKeyword) "content" $page.Plain -}} - {{- $.Scratch.Add "search_index" (slice $entry) -}} +{{- if $.Section -}} + {{- $section := (where site.Pages "Section" $.Section) | intersect (where site.Pages ".Title" "!=" $.Title) -}} + {{- range $index, $page := $section -}} + {{- if and (not $page.Params.ignoreSearch) (ne $page.Type "json") -}} + {{- $title := $page.Title -}} + {{- if $page.Params.bannertext -}} + {{- $title = $page.Params.bannertext -}} {{- end -}} + {{- $entry := dict "section" ($page.Section | humanize) "url" $page.Permalink "title" (htmlEscape $title) "description" (htmlEscape $page.Description) "searchKeyword" (htmlEscape $page.Params.searchKeyword) "content" $page.Plain -}} + {{- $.Scratch.Add "search_index" (slice $entry) -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/themes/microcks/layouts/documentation/index.json b/themes/microcks/layouts/documentation/index.json index 54b754ce..787df827 100644 --- a/themes/microcks/layouts/documentation/index.json +++ b/themes/microcks/layouts/documentation/index.json @@ -10,18 +10,18 @@ {{- $.Scratch.Add "search_index" (slice $entry) -}} {{- end -}} {{- end -}} +{{- end -}} - {{- if .Section -}} - {{- $section := (where site.Pages "Section" .Section) | intersect (where site.Pages ".Title" "!=" .Title) -}} - {{- range $index, $page := $section -}} - {{- if and (not $page.Params.ignoreSearch) (ne $page.Type "json") -}} - {{- $title := $page.Title -}} - {{- if $page.Params.bannertext -}} - {{- $title = $page.Params.bannertext -}} - {{- end -}} - {{- $entry := dict "section" ($page.Section | humanize) "url" $page.Permalink "title" (htmlEscape $title) "description" (htmlEscape $page.Description) "searchKeyword" (htmlEscape $page.Params.searchKeyword) "content" $page.Plain -}} - {{- $.Scratch.Add "search_index" (slice $entry) -}} +{{- if $.Section -}} + {{- $section := (where site.Pages "Section" $.Section) | intersect (where site.Pages ".Title" "!=" $.Title) -}} + {{- range $index, $page := $section -}} + {{- if and (not $page.Params.ignoreSearch) (ne $page.Type "json") -}} + {{- $title := $page.Title -}} + {{- if $page.Params.bannertext -}} + {{- $title = $page.Params.bannertext -}} {{- end -}} + {{- $entry := dict "section" ($page.Section | humanize) "url" $page.Permalink "title" (htmlEscape $title) "description" (htmlEscape $page.Description) "searchKeyword" (htmlEscape $page.Params.searchKeyword) "content" $page.Plain -}} + {{- $.Scratch.Add "search_index" (slice $entry) -}} {{- end -}} {{- end -}} {{- end -}}