From 1af30b8caaa4824ecd3e9785247ee883e30b5f8d Mon Sep 17 00:00:00 2001 From: razonyang Date: Sat, 9 Mar 2024 02:35:06 +0800 Subject: [PATCH] fix: check before parsing headings --- .../partials/search/functions/parse-headings.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/layouts/partials/search/functions/parse-headings.html b/layouts/partials/search/functions/parse-headings.html index d54f1894876..db48e09abee 100644 --- a/layouts/partials/search/functions/parse-headings.html +++ b/layouts/partials/search/functions/parse-headings.html @@ -1,8 +1,10 @@ {{- $headings := slice }} -{{- range .Fragments.HeadingsMap }} - {{- $headings = $headings | append (dict - "anchor" .ID - "title" (.Title | plainify)) - }} +{{- with .Fragments }} + {{- range .HeadingsMap }} + {{- $headings = $headings | append (dict + "anchor" .ID + "title" (.Title | plainify)) + }} + {{- end }} {{- end }} {{- return $headings -}}