From 9e1c85bbddea057fcc42a3b4d3e6ff4478b5b11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 17 Dec 2024 20:24:12 +0100 Subject: [PATCH] Revert "Document PAGE.String" This reverts commit bb30e7c08f471d2d65f7a81ebedc791b185e39ff. We don't want to document this, at least not this way. The PAGE.String method is currently meant to be used to give contextual information about a page (path, filename). It's meant for error messages, so you can do ``` {{ warnf "foo not found in %q" .Page }} ``` But when documented as "Returns the absolute path to the file backing the given page", that is 1. Not entirely correct. 2. Makes it a formal API that people will use as a filename/path, and we can never change it (e.g. to add more contextual information) --- content/en/methods/page/Store.md | 1 + content/en/methods/page/String.md | 45 ------------------------------- 2 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 content/en/methods/page/String.md diff --git a/content/en/methods/page/Store.md b/content/en/methods/page/Store.md index ee0c5b00d..484c27fd5 100644 --- a/content/en/methods/page/Store.md +++ b/content/en/methods/page/Store.md @@ -1,5 +1,6 @@ --- title: Store +linktitle: PAGE.Store description: Returns a persistent "scratch pad" on the given page to store and manipulate data. categories: [] keywords: [] diff --git a/content/en/methods/page/String.md b/content/en/methods/page/String.md deleted file mode 100644 index 5445399bb..000000000 --- a/content/en/methods/page/String.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: String -description: Returns the absolute path to the file backing the given page. -categories: [] -keywords: [] -action: - related: [] - returnType: string - signatures: [PAGE.String] -toc: true ---- - -{{< new-in 0.137.0 >}} - -With content from the file system: - -```go-html-template -{{ .String }} → /home/user/project/content/posts/post-1.md -``` - -With content from a content adapter: - -```go-html-template -{{ .String }} → /home/user/project/content/posts/_content.gotmpl:/posts/post-1.md -``` - -With content from a module: - -```go-html-template -{{ .String }} → /home/user/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/user/hugo-module-content@v0.1.9/content/posts/post-1.md -``` - -Use this method to provide useful information when displaying error and warning messages in the console: - -{{< code file="layouts/partials/featured-image.html" lang="go-html-template" >}} -{{ with .Resources.GetMatch "*featured*" }} - {{ with .Resize "300x webp" }} - - {{ end }} -{{ else }} - {{ errorf "The featured-image partial was unable to find a featured image. See %s" .String }} -{{ end }} -{{< /code >}} - -With shortcodes and render hooks use the `Position` method instead. Note that the `Position` method is not available to heading, image, and link render hooks.