From 9f663a43fa0213f006158838114837dda6d6dfc5 Mon Sep 17 00:00:00 2001 From: Jeff Dairiki Date: Sat, 26 Feb 2022 21:08:58 -0800 Subject: [PATCH] Add notes on passing alt in query arg when resolving links --- content/docs/api/db/obj/url-to/contents.lr | 4 ++++ content/docs/api/db/types/markdown/contents.lr | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/content/docs/api/db/obj/url-to/contents.lr b/content/docs/api/db/obj/url-to/contents.lr index 90f33542..b6dd5d1c 100644 --- a/content/docs/api/db/obj/url-to/contents.lr +++ b/content/docs/api/db/obj/url-to/contents.lr @@ -24,6 +24,10 @@ the path fails, then the path is interpreted as a URL-path, or, if If the path starts with a leading bang (``!``) then no resolving is performed. This is equivalent to passing `resolve=False`. +An explicit value for `alt` may be specified via the `alt` parameter to `url_to`. +Alternatively, an `alt` query arg may be included in the `path` parameter. +For example, `src.url_to('/', alt='de')` is equivalent to `src.url_to('/?alt=de')` — both return the URL to the root of the site with `alt=de`. + If no `alt` is provided the `alt` of the page is used. diff --git a/content/docs/api/db/types/markdown/contents.lr b/content/docs/api/db/types/markdown/contents.lr index f9f26701..338a7aa5 100644 --- a/content/docs/api/db/types/markdown/contents.lr +++ b/content/docs/api/db/types/markdown/contents.lr @@ -70,3 +70,11 @@ label = Body type = markdown resolve_links = never ``` + +## Linking to a Specific Alt + +When links are resolved through the Lektor database, URLs to specific _alt_s may be obtained by adding an `alt` query arg to the link. +For example, to link to the current page, but in the German alt: +```md +Here is the [French version of the blog](/blog?alt=fr). +```