From 02732fe9166aa325e399d440d6a642509ed8b2f0 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Fri, 26 Apr 2024 14:48:28 -0700 Subject: [PATCH] Remove layouts directory --- layouts/_default/_markup/render-link.html | 250 ------------------ layouts/index.rss.xml | 68 ----- layouts/news/list.html | 57 ---- layouts/news/list.xml | 68 ----- .../partials/utilities/get-remote-data.html | 23 -- layouts/shortcodes/new-in.html | 34 --- 6 files changed, 500 deletions(-) delete mode 100644 layouts/_default/_markup/render-link.html delete mode 100644 layouts/index.rss.xml delete mode 100644 layouts/news/list.html delete mode 100644 layouts/news/list.xml delete mode 100644 layouts/partials/utilities/get-remote-data.html delete mode 100644 layouts/shortcodes/new-in.html diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html deleted file mode 100644 index 0e4fe715b..000000000 --- a/layouts/_default/_markup/render-link.html +++ /dev/null @@ -1,250 +0,0 @@ -{{- /* Last modified: 2024-04-26T13:54:00-07:00 */}} - -{{- /* -Copyright 2023 Veriphor LLC - -Licensed under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at - -https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. -*/}} - -{{- /* -This render hook resolves internal destinations by looking for a matching: - - 1. Content page - 2. Page resource (a file in the current page bundle) - 3. Section resource (a file in the current section) - 4. Global resource (a file in the assets directory) - -It skips the section resource lookup if the current page is a leaf bundle. - -External destinations are not modified. - -You must place global resources in the assets directory. If you have placed -your resources in the static directory, and you are unable or unwilling to move -them, you must mount the static directory to the assets directory by including -both of these entries in your site configuration: - - [[module.mounts]] - source = 'assets' - target = 'assets' - - [[module.mounts]] - source = 'static' - target = 'assets' - -By default, if this render hook is unable to resolve a destination, including a -fragment if present, it passes the destination through without modification. To -emit a warning or error, set the error level in your site configuration: - - [params.render_hooks.link] - errorLevel = 'warning' # ignore (default), warning, or error (fails the build) - -When you set the error level to warning, and you are in a development -environment, you can visually highlight broken internal links: - - [params.render_hooks.link] - errorLevel = 'warning' # ignore (default), warning, or error (fails the build) - highlightBroken = true # true or false (default) - -This will add a "broken" class to anchor elements with invalid src attributes. -Add a rule to your CSS targeting the broken links: - - a.broken { - background: #ff0; - border: 2px solid #f00; - padding: 0.1em 0.2em; - } - -This render hook may be unable to resolve destinations created with the ref and -relref shortcodes. Unless you set the error level to ignore you should not use -either of these shortcodes in conjunction with this render hook. - -@context {string} Destination The link destination. -@context {page} Page A reference to the page containing the link. -@context {string} PlainText The link description as plain text. -@context {string} Text The link description. -@context {string} Title The link title. - -@returns {template.html} -*/}} - -{{- /* Initialize. */}} -{{- $renderHookName := "link" }} - -{{- /* Verify minimum required version. */}} -{{- $minHugoVersion := "0.120.0" }} -{{- if lt hugo.Version $minHugoVersion }} - {{- errorf "The %q render hook requires Hugo v%s or later." $renderHookName $minHugoVersion }} -{{- end }} - -{{- /* Error level when unable to resolve destination: ignore, warning, or error. */}} -{{- $errorLevel := or site.Params.render_hooks.link.errorLevel "ignore" | lower }} - -{{- /* If true, adds "broken" class to broken links. Applicable in development environment when errorLevel is warning. */}} -{{- $highlightBrokenLinks := or site.Params.render_hooks.link.highlightBroken false }} - -{{- /* Validate error level. */}} -{{- if not (in (slice "ignore" "warning" "error") $errorLevel) }} - {{- errorf "The %q render hook is misconfigured. The errorLevel %q is invalid. Please check your site configuration." $renderHookName $errorLevel }} -{{- end }} - -{{- /* Determine content path for warning and error messages. */}} -{{- $contentPath := "" }} -{{- with .Page.File }} - {{- $contentPath = .Path }} -{{- else }} - {{- $contentPath = .Path }} -{{- end }} - -{{- /* Parse destination. */}} -{{- $u := urls.Parse .Destination }} - -{{- /* Set common message. */}} -{{- $msg := printf "The %q render hook was unable to resolve the destination %q in %s" $renderHookName $u.String $contentPath }} - -{{- /* Set attributes for anchor element. */}} -{{- $attrs := dict "href" $u.String }} -{{- if $u.IsAbs }} - {{- /* Destination is a remote resource. */}} - {{- $attrs = merge $attrs (dict "rel" "external") }} -{{- else }} - {{- with $u.Path }} - {{- with $p := or ($.PageInner.GetPage .) ($.PageInner.GetPage (strings.TrimRight "/" .)) }} - {{- /* Destination is a page. */}} - {{- $href := .RelPermalink }} - {{- with $u.RawQuery }} - {{- $href = printf "%s?%s" $href . }} - {{- end }} - {{- with $u.Fragment }} - {{- $ctx := dict - "contentPath" $contentPath - "errorLevel" $errorLevel - "page" $p - "parsedURL" $u - "renderHookName" $renderHookName - }} - {{- partial "inline/h-rh-l/validate-fragment.html" $ctx }} - {{- $href = printf "%s#%s" $href . }} - {{- end }} - {{- $attrs = dict "href" $href }} - {{- else }} - {{- with $.PageInner.Resources.Get $u.Path }} - {{- /* Destination is a page resource; drop query and fragment. */}} - {{- $attrs = dict "href" .RelPermalink }} - {{- else }} - {{- with (and (ne $.Page.BundleType "leaf") ($.Page.CurrentSection.Resources.Get $u.Path)) }} - {{- /* Destination is a section resource, and current page is not a leaf bundle. */}} - {{- $attrs = dict "href" .RelPermalink }} - {{- else }} - {{- with resources.Get $u.Path }} - {{- /* Destination is a global resource; drop query and fragment. */}} - {{- $attrs = dict "href" .RelPermalink }} - {{- else }} - {{- if eq $errorLevel "warning" }} - {{- warnf $msg }} - {{- if and $highlightBrokenLinks hugo.IsDevelopment }} - {{- $attrs = merge $attrs (dict "class" "broken") }} - {{- end }} - {{- else if eq $errorLevel "error" }} - {{- errorf $msg }} - {{- end }} - {{- end }} - {{- end }} - {{- end }} - {{- end }} - {{- else }} - {{- with $u.Fragment }} - {{- /* Destination is on the same page; prepend relative permalink. */}} - {{- $ctx := dict - "contentPath" $contentPath - "errorLevel" $errorLevel - "page" $.Page - "parsedURL" $u - "renderHookName" $renderHookName - }} - {{- partial "inline/h-rh-l/validate-fragment.html" $ctx }} - {{- $attrs = dict "href" (printf "%s#%s" $.Page.RelPermalink .) }} - {{- else }} - {{- if eq $errorLevel "warning" }} - {{- warnf $msg }} - {{- if and $highlightBrokenLinks hugo.IsDevelopment }} - {{- $attrs = merge $attrs (dict "class" "broken") }} - {{- end }} - {{- else if eq $errorLevel "error" }} - {{- errorf $msg }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} -{{- $attrs = merge $attrs (dict "title" (.Title | transform.HTMLEscape)) }} - -{{- /* Render anchor element. */ -}} -{{ .Text | safeHTML }} - -{{- define "partials/inline/h-rh-l/validate-fragment.html" }} - {{- /* - Validates the fragment portion of a link destination. - - @context {string} contentPath The page containing the link. - @context {string} errorLevel The error level when unable to resolve destination; ignore (default), warning, or error. - @context {page} page The page corresponding to the link destination - @context {struct} parsedURL The link destination parsed by urls.Parse. - @context {string} renderHookName The name of the render hook. - */}} - - {{- /* Initialize. */}} - {{- $contentPath := .contentPath }} - {{- $errorLevel := .errorLevel }} - {{- $p := .page }} - {{- $u := .parsedURL }} - {{- $renderHookName := .renderHookName }} - - {{- /* Validate. */}} - {{- with $u.Fragment }} - {{- if $p.Fragments.Identifiers.Contains . }} - {{- if gt ($p.Fragments.Identifiers.Count .) 1 }} - {{- $msg := printf "The %q render hook detected duplicate heading IDs %q in %s" $renderHookName . $contentPath }} - {{- if eq $errorLevel "warning" }} - {{- warnf $msg }} - {{- else if eq $errorLevel "error" }} - {{- errorf $msg }} - {{- end }} - {{- end }} - {{- else }} - {{- /* Determine target path for warning and error message. */}} - {{- $targetPath := "" }} - {{- with $p.File }} - {{- $targetPath = .Path }} - {{- else }} - {{- $targetPath = .Path }} - {{- end }} - {{- /* Set common message. */}} - {{- $msg := printf "The %q render hook was unable to find heading ID %q in %s. See %s" $renderHookName . $targetPath $contentPath }} - {{- if eq $targetPath $contentPath }} - {{- $msg = printf "The %q render hook was unable to find heading ID %q in %s" $renderHookName . $targetPath }} - {{- end }} - {{- /* Throw warning or error. */}} - {{- if eq $errorLevel "warning" }} - {{- warnf $msg }} - {{- else if eq $errorLevel "error" }} - {{- errorf $msg }} - {{- end }} - {{- end }} - {{- end }} - -{{- end -}} diff --git a/layouts/index.rss.xml b/layouts/index.rss.xml deleted file mode 100644 index 26afc1816..000000000 --- a/layouts/index.rss.xml +++ /dev/null @@ -1,68 +0,0 @@ -{{- printf "" | safeHTML }} - - - Hugo News - Recent news about Hugo, a static site generator written in Go, optimized for speed and designed for flexibility. - {{ .Permalink }} - Hugo {{ hugo.Version }} - {{ or site.Language.LanguageCode site.Language.Lang }} - {{- with site.Copyright }} - {{ . }} - {{- end }} - {{- with .OutputFormats.Get "RSS" }} - {{ printf "" .Permalink .MediaType | safeHTML }} - {{- end }} - - {{- $news_items := slice }} - - {{- /* Get releases from GitHub. */}} - {{- $u := "https://api.github.com/repos/gohugoio/hugo/releases" }} - {{- $releases := partial "utilities/get-remote-data.html" $u }} - {{- $releases = where $releases "draft" false }} - {{- $releases = where $releases "prerelease" false }} - {{- range $releases | first 20 }} - {{- $summary := printf - "Hugo %s was released on %s. See [release notes](%s) for details." - .tag_name - (.published_at | time.AsTime | time.Format "2 Jan 2006") - .html_url - }} - {{- $ctx := dict - "PublishDate" (.published_at | time.AsTime) - "Title" (printf "Release %s" .name) - "Permalink" .html_url - "Section" "news" - "Summary" ($summary | $.Page.RenderString) - }} - {{- $news_items = $news_items | append $ctx }} - {{- end }} - - {{- /* Get content pages from news section. */}} - {{- range where site.RegularPages "Section" "news" }} - {{- $ctx := dict - "PublishDate" .PublishDate - "Title" .Title - "RelPermalink" .RelPermalink - "Section" "news" - "Summary" .Summary - "Params" (dict "description" .Description) - }} - {{- $news_items = $news_items | append $ctx }} - {{- end }} - {{- /* Sort, limit, and render lastBuildDate. */}} - {{- $limit := cond (gt site.Config.Services.RSS.Limit 1) site.Config.Services.RSS.Limit 999 }} - {{- $news_items = sort $news_items "PublishDate" "desc" | first $limit }} - {{ (index $news_items 0).PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - - {{- /* Render items. */}} - {{- range $news_items }} - - {{ .Title }} - {{ .Permalink }} - {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ .Permalink }} - {{ .Summary | transform.XMLEscape | safeHTML }} - - {{- end }} - - diff --git a/layouts/news/list.html b/layouts/news/list.html deleted file mode 100644 index a41e45a2c..000000000 --- a/layouts/news/list.html +++ /dev/null @@ -1,57 +0,0 @@ -{{ define "main" }} -
- -
-

- {{ .Title }} -

-
- {{ .Content }} -
-
- -
- {{ $interior_classes := $.Site.Params.flex_box_interior_classes }} -
- - {{ $news_items := slice }} - - {{/* Get releases from GitHub. */}} - {{ $u := "https://api.github.com/repos/gohugoio/hugo/releases" }} - {{ $releases := partial "utilities/get-remote-data.html" $u }} - {{ $releases = where $releases "draft" false }} - {{ $releases = where $releases "prerelease" false }} - {{ range $releases | first 20 }} - {{ $ctx := dict - "Date" (.published_at | time.AsTime) - "Title" (printf "Release %s" .name) - "Permalink" .html_url - "Section" "news" - "Summary" "" - }} - {{ $news_items = $news_items | append $ctx }} - {{ end }} - - {{/* Get content pages from news section. */}} - {{ range .Pages }} - {{ $ctx := dict - "Date" .Date - "Title" .Title - "RelPermalink" .RelPermalink - "Section" "news" - "Summary" .Summary - "Params" (dict "description" .Description) - }} - {{ $news_items = $news_items | append $ctx }} - {{ end }} - - {{/* Sort by date (descending) and render. */}} - {{ range sort $news_items "Date" "desc" }} - {{ partial "boxes-section-summaries.html" (dict "context" . "classes" $interior_classes "fullcontent" false) }} - {{ end }} - -
-
- -
-{{ end }} diff --git a/layouts/news/list.xml b/layouts/news/list.xml deleted file mode 100644 index 40bca59eb..000000000 --- a/layouts/news/list.xml +++ /dev/null @@ -1,68 +0,0 @@ -{{- printf "" | safeHTML }} - - - Hugo News - Recent news about Hugo, a static site generator written in Go, optimized for speed and designed for flexibility. - {{ .Permalink }} - Hugo {{ hugo.Version }} - {{ or site.Language.LanguageCode site.Language.Lang }} - {{- with site.Copyright }} - {{ . }} - {{- end }} - {{- with .OutputFormats.Get "RSS" }} - {{ printf "" .Permalink .MediaType | safeHTML }} - {{- end }} - - {{- $news_items := slice }} - - {{- /* Get releases from GitHub. */}} - {{- $u := "https://api.github.com/repos/gohugoio/hugo/releases" }} - {{- $releases := partial "utilities/get-remote-data.html" $u }} - {{- $releases = where $releases "draft" false }} - {{- $releases = where $releases "prerelease" false }} - {{- range $releases | first 20 }} - {{- $summary := printf - "Hugo %s was released on %s. See [release notes](%s) for details." - .tag_name - (.published_at | time.AsTime | time.Format "2 Jan 2006") - .html_url - }} - {{- $ctx := dict - "PublishDate" (.published_at | time.AsTime) - "Title" (printf "Release %s" .name) - "Permalink" .html_url - "Section" "news" - "Summary" ($summary | $.Page.RenderString) - }} - {{- $news_items = $news_items | append $ctx }} - {{- end }} - - {{- /* Get content pages from news section. */}} - {{- range .Pages }} - {{- $ctx := dict - "PublishDate" .PublishDate - "Title" .Title - "RelPermalink" .RelPermalink - "Section" "news" - "Summary" .Summary - "Params" (dict "description" .Description) - }} - {{- $news_items = $news_items | append $ctx }} - {{- end }} - {{- /* Sort, limit, and render lastBuildDate. */}} - {{- $limit := cond (gt site.Config.Services.RSS.Limit 1) site.Config.Services.RSS.Limit 999 }} - {{- $news_items = sort $news_items "PublishDate" "desc" | first $limit }} - {{ (index $news_items 0).PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - - {{- /* Render items. */}} - {{- range $news_items }} - - {{ .Title }} - {{ .Permalink }} - {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ .Permalink }} - {{ .Summary | transform.XMLEscape | safeHTML }} - - {{- end }} - - diff --git a/layouts/partials/utilities/get-remote-data.html b/layouts/partials/utilities/get-remote-data.html deleted file mode 100644 index 69ac41da4..000000000 --- a/layouts/partials/utilities/get-remote-data.html +++ /dev/null @@ -1,23 +0,0 @@ -{{/* -Parses the serialized data from the given URL and returns a map or an array. - -Supports CSV, JSON, TOML, YAML, and XML. - -@param {string} . The URL from which to retrieve the serialized data. -@returns {any} - -@example {{ partial "get-remote-data.html" "https://example.org/foo.json" }} -*/}} - -{{ $url := . }} -{{ $data := dict }} -{{ with resources.GetRemote $url }} - {{ with .Err }} - {{ errorf "%s" . }} - {{ else }} - {{ $data = .Content | transform.Unmarshal }} - {{ end }} -{{ else }} - {{ errorf "Unable to get remote resource %q" $url }} -{{ end }} -{{ return $data }} diff --git a/layouts/shortcodes/new-in.html b/layouts/shortcodes/new-in.html deleted file mode 100644 index 606d2219c..000000000 --- a/layouts/shortcodes/new-in.html +++ /dev/null @@ -1,34 +0,0 @@ -{{- /* -Renders a "new in" button indicating the version in which a feature was added. - -When comparing the current version to the specified version, the "new in" -button will be hidden if any of the following conditions is true: - -- The major version difference exceeds the majorVersionDiffThreshold -- The minor version difference exceeds the minorVersionDiffThreshold - -@param {string} version The semantic version string, with or without a leading v. -@returns {template.HTML} - -@example {{< new-in 0.100.0 >}} -*/}} - -{{- /* Set defaults. */}} -{{- $majorVersionDiffThreshold := 0 }} -{{- $minorVersionDiffThreshold := 30 }} -{{- $displayExpirationWarning := true }} - -{{- /* Render. */}} -{{- with $version := .Get 0 | strings.TrimPrefix "v" }} - {{- $majorVersionDiff := sub (index (split hugo.Version ".") 0 | int) (index (split $version ".") 0 | int) }} - {{- $minorVersionDiff := sub (index (split hugo.Version ".") 1 | int) (index (split $version ".") 1 | int) }} - {{- if or (gt $majorVersionDiff $majorVersionDiffThreshold) (gt $minorVersionDiff $minorVersionDiffThreshold) }} - {{- if $displayExpirationWarning }} - {{- warnf "This call to the %q shortcode should be removed: %s. The button is now hidden because the specified version (%s) is older than the display threshold." $.Name $.Position $version }} - {{- end }} - {{- else }} - New in v{{ $version }} - {{- end }} -{{- else }} - {{- errorf "The %q shortcode requires a positional parameter (version). See %s" .Name .Position }} -{{- end -}}