hugo/hugolib
Bjørn Erik Pedersen 90da7664bf Add page fragments support to Related
The main topic of this commit is that you can now index fragments (content heading identifiers) when calling `.Related`.

You can do this by:

* Configure one or more indices with type `fragments`
* The name of those index configurations maps to an (optional) front matter slice with fragment references. This allows you to link
page<->fragment and page<->page.
* This also will index all the fragments (heading identifiers) of the pages.

It's also possible to use type `fragments` indices in shortcode, e.g.:

```
{{ $related := site.RegularPages.Related .Page }}
```

But, and this is important, you need to include the shortcode using the `{{<` delimiter. Not doing so will create infinite loops and timeouts.

This commit also:

* Adds two new methods to Page: Fragments (can also be used to build ToC) and HeadingsFiltered (this is only used in Related Content with
index type `fragments` and `enableFilter` set to true.
* Consolidates all `.Related*` methods into one, which takes either a `Page` or an options map as its only argument.
* Add `context.Context` to all of the content related Page API. Turns out it wasn't strictly needed for this particular feature, but it will
soon become usefil, e.g. in #9339.

Closes #10711
Updates #9339
Updates #10725
2023-02-21 17:56:41 +01:00
..
assets/images
filesystems Also consider wrapped errors when checking for file IsNotExist errors 2022-12-14 13:51:06 +01:00
paths Fix relURL with leading slash when baseURL includes a subdirectory 2022-06-13 11:40:25 +02:00
testdata
testsite
404_test.go
alias.go
alias_test.go
breaking_changes_test.go
cascade_test.go
codeowners.go Also consider wrapped errors when checking for file IsNotExist errors 2022-12-14 13:51:06 +01:00
collections.go
collections_test.go
config.go Make hugo.toml the new config.toml 2023-01-16 15:34:16 +01:00
config_test.go Make hugo.toml the new config.toml 2023-01-16 15:34:16 +01:00
configdir_test.go
content_factory.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
content_factory_test.go Add --force to hugo new 2022-09-08 15:35:11 +02:00
content_map.go
content_map_page.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
content_map_test.go
content_render_hooks_test.go Make .RenderString render shortcodes 2022-05-30 11:32:55 +02:00
datafiles_test.go
dates_test.go Fix raw TOML dates in where/eq 2022-06-07 13:02:58 +02:00
disableKinds_test.go
embedded_shortcodes_test.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
embedded_templates_test.go
fileInfo.go
fileInfo_test.go
frontmatter_test.go Preserve front matter slice value types (e.g. int) 2023-01-17 08:58:05 +01:00
gitinfo.go Misc doc, code refactoring to improve documentation 2023-01-04 18:01:26 +01:00
hugo_modules_test.go
hugo_sites.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
hugo_sites_build.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
hugo_sites_build_errors_test.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
hugo_sites_build_test.go modules: Make the module.workspace=off as default (note) 2022-12-19 20:17:33 +01:00
hugo_sites_multihost_test.go
hugo_sites_rebuild_test.go
hugo_smoke_test.go Make the baseline benchmark's test files stable 2022-06-30 12:36:55 +02:00
image_test.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
integration_test.go Annotate test assertions 2022-12-22 18:53:12 +01:00
integrationtest_builder.go Make hugo.toml the new config.toml 2023-01-16 15:34:16 +01:00
language_content_dir_test.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
language_test.go
menu_test.go
minify_publisher_test.go Revert "tpl/tplimpl: Use https in sitemap templates" 2022-12-22 08:53:58 +01:00
mount_filters_test.go
multilingual.go
page.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
page__common.go Misc doc, code refactoring to improve documentation 2023-01-04 18:01:26 +01:00
page__content.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
page__data.go
page__menus.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
page__meta.go Preserve front matter slice value types (e.g. int) 2023-01-17 08:58:05 +01:00
page__new.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
page__output.go Revise the fix for shortcode vs output format nilpointer 2022-10-26 13:00:21 +02:00
page__paginator.go
page__paths.go
page__per_output.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
page__position.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
page__ref.go
page__tree.go resource/page: Slight adjustment of Page.Ancestors 2022-12-23 10:14:53 +01:00
page_kinds.go
page_permalink_test.go modules: Make the module.workspace=off as default (note) 2022-12-19 20:17:33 +01:00
page_test.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
page_unwrap.go
page_unwrap_test.go
pagebundler_test.go
pagecollections.go
pagecollections_test.go
pages_capture.go Also consider wrapped errors when checking for file IsNotExist errors 2022-12-14 13:51:06 +01:00
pages_capture_test.go
pages_language_merge_test.go
pages_process.go Fix /static performance regression from Hugo 0.103.0 2022-09-26 19:02:25 +02:00
pages_test.go
paginator_test.go
permalinker.go
prune_resources.go
renderstring_test.go Fix shortcode detection in RenderString 2023-01-26 11:41:07 +01:00
resource_chain_test.go Only invoke a given cached partial once 2023-01-25 17:35:23 +01:00
robotstxt_test.go
rss_test.go
securitypolicies_test.go
shortcode.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
shortcode_page.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
shortcode_test.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
site.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
site_benchmark_new_test.go
site_output.go
site_output_test.go
site_render.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
site_sections.go
site_sections_test.go resource/page: Add Page.Ancestors 2022-12-23 10:14:53 +01:00
site_stats_test.go
site_test.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
site_url_test.go
siteJSONEncode_test.go
sitemap_test.go
taxonomy_test.go Fix taxonomy weight sort regression 2022-11-01 18:45:34 +01:00
template_test.go
testhelpers_test.go Add page fragments support to Related 2023-02-21 17:56:41 +01:00
translations.go hugolib: Exclude non-linkable pages from translations map 2022-12-22 18:53:12 +01:00