Skip to content

Commit

Permalink
search: rank older manual page versions lower
Browse files Browse the repository at this point in the history
Old manual page versions are almost always uninteresting. So let's avoid
showing them first thing.

This feat is accomplished by using the `data-pagefind-weight` attribute
(which affects also the header tags that would usually rank higher in
the search index: the `data-pagefind-weight` attribute extends not only
the tag but all of its child nodes, too, recursively).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Oct 18, 2023
1 parent 197582a commit e9fa963
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ <h1>{{ .Params.book.section.cs_number }} {{ .Params.book.chapter.title }} - {{ .
{{ partial "ref/versions.html" . }}
</div>

<div id="main" data-pagefind-body>
<!-- older manual page versions are less interesting -->
{{ $reduce_weight := (and (isset .Params "docname") (not (isset .Params "latest-changes"))) }}
<div id="main"{{ if $reduce_weight }} data-pagefind-weight="0.5"{{ end }} data-pagefind-body>
{{ .Content }}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions script/update-docs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ def index_doc(filter_tags, doc_list, get_content)
if page_data["latest-changes"] == version
FileUtils.mkdir_p(File.dirname(doc_path))
File.open("#{doc_path}.html", "w") do |out|
front_matter["latest-changes"] = version
front_matter["aliases"] = ["/docs/#{docname}", "/docs/#{docname}.html"]
out.write("#{front_matter.to_yaml}\n---\n")
out.write(html)
Expand Down

0 comments on commit e9fa963

Please sign in to comment.