Related Posts Based on Heading

Is the current implementation of related posts not working when it comes to fragments and headings?
It seems to work for exact match headings but not single word matching.

ie:

\# Summary

\# Summary

would match, but:

\# Awesome Topic

\# Super Topic

Doesn’t match on the word Topic or at all since it’s not an exact match on the whole heading.

I’ve found a workaround using GPT:

{{ $currentPage := . }}
{{ $currentWords := slice }}

{{/* 1. Extract and tokenize heading words from current page /}}
{{ range findRE (?i)<h[2-3][^>]*>(.*?)</h[2-3]> $currentPage.Content }}
{{ $cleanHeading := . | plainify | lower }}
{{ range split (replaceRE [^a-z0-9\s] "" $cleanHeading) " " }}
{{/ Filter out short noise words and common stop-words /}}
{{ if and (gt (len .) 3) (not (in (slice "this" "that" "with" "from" "have" "about" "using" "guide" "setup" "overview") .)) }}
{{ $currentWords = $currentWords | append . }}
{{ end }}
{{ end }}
{{ end }}
{{ $currentWords = $currentWords | uniq }}
{{/ 2. Compare against all other regular pages /}}
{{ $relatedMatches := slice }}
{{ range where site.RegularPages "Permalink" "!=" $currentPage.Permalink }}
{{ $otherPage := . }}
{{ $otherWords := slice }}
{{ range findRE (?i)<h[2-3][^>]*>(.*?)</h[2-3]> $otherPage.Content }}
{{ $cleanHeading := . | plainify | lower }}
{{ range split (replaceRE [^a-z0-9\s] "" $cleanHeading) " " }}
{{ $otherWords = $otherWords | append . }}
{{ end }}
{{ end }}
{{/ 3. Count shared heading words between pages /}}
{{ $sharedWords := intersect $currentWords $otherWords }}
{{ if gt (len $sharedWords) 0 }}
{{ $relatedMatches = $relatedMatches | append (dict "page" $otherPage "score" (len $sharedWords) "matched" $sharedWords) }}
{{ end }}
{{ end }}
{{/ 4. Display top 5 pages sorted by highest word overlap */}}
{{ $sortedRelated := sort $relatedMatches "score" "desc" | first 5 }}
{{ with $sortedRelated }}

<section class="related-posts">
    <h3>Related Articles:</h3>
    <ul>
      {{ range . }}
        <li>
          <a href="{{ .page.RelPermalink }}">{{ .page.Title }}</a>
        </li>
      {{ end }}
    </ul>
  </section>
{{ end }}

But I would still like a the native heading fragments to be fixed.

See:

This is addressed in v0.166.0 with the new tokenize and (optionally) minTokenLength configuration parameters.