From nobody Sat Mar 23 17:58:14 2024 X-Original-To: dev-commits-doc-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4V26PL6xd8z5FXwZ for ; Sat, 23 Mar 2024 17:58:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4V26PL6P2tz41qQ; Sat, 23 Mar 2024 17:58:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711216694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=628bFwThTcuh2iaiSz82tosXo4YG1RoId13hRjwOtCA=; b=Ke6YMXgsHwTHzpP/t7zcr8xJFt4AwiLX0s9wBJy44mv8imfP4xxRwIoQ/1hj4XNfAr6hQC VPsW/ToOejURioqTuvTINx9WJxrzyLiufHddWsxV1+Vw+8/85BOeHTj0FTWfsfxe1hqKoA k7dJ6KszLctDO6yBwdL3qNH6gqoBnyHvinoioSHDAmj5soua18SnbBajXaIuR28x0kBmRE lK9JLhmkT7coeQ+dpsgIqhCxoin8NHWh+ZIFPb3G5XcDTh2gZDZc4sS3ATbVEwhPDMu87s 9Pq9X8QCorouZLeU1jlU/OOFWY0GlhaNyoywld909owQmVsH50wOtBN2O5FKnw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1711216694; a=rsa-sha256; cv=none; b=Ak8w+PJkCT8d9KotydB/5+yl+u9W3prq0m9aSjW3HMzKROMTM0GpybEcf3I/hce6ghTBvO Nkep1cbhbYAaHvMM8xdX55j4Esj5ErUoTr4EM6KeHj1RgG6DpNm0WcV8vz3lYVsjh7Cfgh gAryavKd8abLBOLoA3dGtRkTUsTxQDYjXwZhJWHZ5+/Wt/MmPqusbXZYuI2bdcKxQ5IKv3 VLpZPd6TyT7ZdOWSVyZCn2VOUUl22yIs0uZL0/8IataA5q5ZRh/8jgXYHJf14XEekpe7AZ fXeeGaWtiH6ytu5YMjs6zLnoA7OtuiAcf3blKt2tYIKTyRBhK4zLL1BQfuay8w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711216694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=628bFwThTcuh2iaiSz82tosXo4YG1RoId13hRjwOtCA=; b=x+HnEkahIRUvRapdAsLbx9dAGCWdMSMJrK/WNrMDJgyF8L4rB7xQN1OTN1MzgM+500brYI DvdYv9b/H5CDcTvNYP+XuHdEppIGpcBMOX6jYIHsp7HrTDFZ8w5wt9sEw7V5d4QVLQha4V pMxEtRw+mA5X4DFbZxmXm1/+HYlJKdctgR8Sk3eWTALYgrwK8mCYFod5fSTP0oR/UkJR3u MDA7oP9xYduJ6Mfn8VN88fiEsuw9ffM/oRPRyh/WmIOoc9GrkvILBpT+b8kWyPql7PCulZ Ob1bRJTaifD9Zay5VAwYPhZdCcNGoK73oripO7x/unRAdrVpdLKmmEC428BGjQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4V26PL5tDQzyRm; Sat, 23 Mar 2024 17:58:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42NHwErf007896; Sat, 23 Mar 2024 17:58:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42NHwE20007893; Sat, 23 Mar 2024 17:58:14 GMT (envelope-from git) Date: Sat, 23 Mar 2024 17:58:14 GMT Message-Id: <202403231758.42NHwE20007893@gitrepo.freebsd.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: "Danilo G. Baio" Subject: git: 2a6bab6bd4 - main - documentation/themes: Refactor for Hugo 0.123.X compatibility List-Id: Commit messages for all branches of the doc repository List-Archive: https://lists.freebsd.org/archives/dev-commits-doc-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-doc-all@freebsd.org X-BeenThere: dev-commits-doc-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dbaio X-Git-Repository: doc X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2a6bab6bd4a181f1c4cdd2c166a811899aea7776 Auto-Submitted: auto-generated The branch main has been updated by dbaio: URL: https://cgit.FreeBSD.org/doc/commit/?id=2a6bab6bd4a181f1c4cdd2c166a811899aea7776 commit 2a6bab6bd4a181f1c4cdd2c166a811899aea7776 Author: Danilo G. Baio AuthorDate: 2024-03-09 13:12:57 +0000 Commit: Danilo G. Baio CommitDate: 2024-03-23 17:50:54 +0000 documentation/themes: Refactor for Hugo 0.123.X compatibility - Simplify path extraction logic in menu partial to match only with the main document/book, enhancing maintainability and future Hugo compatibility. - Optimize articles and books directory listings by leveraging Hugo's built-in .Sections to fetch content, replacing manual slice construction and sorting logic. This approach streamlines the code and is more idiomatic with recent Hugo versions. - These changes are part of necessary adjustments for the upgrade to Hugo version 0.123.X, ensuring our theme's compatibility and taking advantage of Hugo's latest features and performance improvements. Reviewed by: fernape Differential Revision: https://reviews.freebsd.org/D44284 --- .../themes/beastie/layouts/partials/menu.html | 10 ++++++- .../shortcodes/list-articles-directories.html | 32 +++------------------ .../layouts/shortcodes/list-books-directories.html | 33 ++++------------------ 3 files changed, 18 insertions(+), 57 deletions(-) diff --git a/documentation/themes/beastie/layouts/partials/menu.html b/documentation/themes/beastie/layouts/partials/menu.html index 1b3ddf3b7d..e189abad53 100644 --- a/documentation/themes/beastie/layouts/partials/menu.html +++ b/documentation/themes/beastie/layouts/partials/menu.html @@ -1,4 +1,12 @@ -{{ with .Site.GetPage .Params.path }} +{{/* always extract the first part of the path to match it only with the main document/book. */}} +{{ $path := "" }} +{{ $regex := `^(\/[^\/]+\/[^\/]+)` }} +{{ $matches := findRE $regex .Params.path }} +{{ if gt (len $matches) 0 }} + {{ $path = index $matches 0 }} +{{ end }} + +{{ with .Site.GetPage $path }}
    {{ range .Pages }}
  • diff --git a/documentation/themes/beastie/layouts/shortcodes/list-articles-directories.html b/documentation/themes/beastie/layouts/shortcodes/list-articles-directories.html index 843300d4aa..33eab8f495 100644 --- a/documentation/themes/beastie/layouts/shortcodes/list-articles-directories.html +++ b/documentation/themes/beastie/layouts/shortcodes/list-articles-directories.html @@ -1,14 +1,3 @@ -{{ $articles := slice}} - -{{ range where .Site.Pages "Section" "articles" }} - {{ with .File }} - {{ $subDirsNumer := .File.Path | strings.Count "/" }} - {{ if eq $subDirsNumer 2 }} - {{ $articles = $articles | append (dict "page" . "path" .File.Path) }} - {{ end }} - {{ end }} -{{ end }} - {{ partial "global-search.html" . }}

    {{ i18n "articles" }}

    @@ -17,25 +6,12 @@
    -{{ $articles := slice}} - -{{ range where .Site.Pages "Section" "articles" }} - {{ $subDirsNumer := .File.Path | strings.Count "/" }} - {{ if eq $subDirsNumer 2 }} - {{ $articles = $articles | append (dict "page" . "path" .File.Path) }} - {{ end }} -{{ end }} -
      -{{ range sort $articles "weight" "path" }} - {{ if in .path "_index.adoc" }} - {{ $articlePath := replaceRE "/_index.adoc" "" .path }} - {{ $articlePath = replaceRE "articles/" "" $articlePath }} - {{ $articleName := replaceRE "articles/" "" $articlePath }} +{{ $articles := .Site.GetPage "section" "articles" }} +{{ range $articles.Sections }}
    • - {{ .page.Title }} -

      {{ .page.Params.description }}

      + {{ .Title }} +

      {{ .Params.description }}

    • - {{ end }} {{ end }}
    diff --git a/documentation/themes/beastie/layouts/shortcodes/list-books-directories.html b/documentation/themes/beastie/layouts/shortcodes/list-books-directories.html index 10df5da34c..d98353f942 100644 --- a/documentation/themes/beastie/layouts/shortcodes/list-books-directories.html +++ b/documentation/themes/beastie/layouts/shortcodes/list-books-directories.html @@ -1,14 +1,3 @@ -{{ $books := slice}} - -{{ range where .Site.Pages "Section" "books" }} - {{ with .File }} - {{ $subDirsNumer := .File.Path | strings.Count "/" }} - {{ if eq $subDirsNumer 2 }} - {{ $books = $books | append (dict "page" . "path" .File.Path) }} - {{ end }} - {{ end }} -{{ end }} - {{ partial "global-search.html" . }}

    {{ i18n "books" }}

    @@ -17,25 +6,13 @@
    -{{ $books := slice}} - -{{ range where .Site.Pages "Section" "books" }} - {{ $subDirsNumer := .File.Path | strings.Count "/" }} - {{ if eq $subDirsNumer 2 }} - {{ $books = $books | append (dict "page" . "path" .File.Path) }} - {{ end }} -{{ end }} -
      -{{ range sort $books "bookOrder" "path" }} - {{ if in .path "_index.adoc" }} - {{ $bookPath := replaceRE "/_index.adoc" "" .path }} - {{ $bookPath = replaceRE "books/" "" $bookPath }} - {{ $articleName := replaceRE "books/" "" $bookPath }} + +{{ $books := .Site.GetPage "section" "books" }} +{{ range $books.Sections }}
    • - {{ .page.Title }} -

      {{ .page.Params.description }}

      + {{ .Title }} +

      {{ .Params.description }}

    • - {{ end }} {{ end }}