diff --git a/content/en/about/contribute/creating-and-editing-pages/index.md b/content/en/about/contribute/creating-and-editing-pages/index.md index 4d83070b25..c4332770ad 100644 --- a/content/en/about/contribute/creating-and-editing-pages/index.md +++ b/content/en/about/contribute/creating-and-editing-pages/index.md @@ -401,6 +401,7 @@ The available attributes are: |`downloadas` | The default file name used when the user [downloads the preformatted block](#download-name). |`expandlinks` | Whether or not to expand [GitHub file references](#links-to-github-files) in the preformatted block. |`snippet` | The name of the [snippet](#snippets) of content to extract from the preformatted block. +|`repo` | The repo to use for [GitHub links](#links-to-github-files) embedded in preformatted blocks. ### Inline vs. imported content @@ -467,6 +468,21 @@ Which renders as: $ kubectl apply -f @samples/bookinfo/networking/virtual-service-reviews-v3.yaml@ {{< /text >}} +Normally, links will point to the current release branch of the `istio/istio` repo. If you'd like a link +that points to a different Istio repo instead, you can use the `repo` attribute: + +{{< text markdown >}} +{{}} +$ cat @README.md@ +{{}} +{{< /text >}} + +which renders as: + +{{< text syntax="bash" repo="operator" >}} +$ cat @README.md@ +{{< /text >}} + If your preformatted content happens to use @ symbols for something else, you can turn off link expansion using the `expandlinks` attribute: diff --git a/data/args.yml b/data/args.yml index eedde93042..0964667d3b 100644 --- a/data/args.yml +++ b/data/args.yml @@ -25,7 +25,7 @@ archive_date: YYYY-MM-DD archive_search_refinement: "V1.1" # GitHub branch names used when the docs have links to GitHub -source_branch_name: master +source_branch_name: release-1.3 doc_branch_name: master # The list of supported versions described by the docs diff --git a/layouts/partials/code_block.html b/layouts/partials/code_block.html index 4dec5eba0b..dab3424809 100644 --- a/layouts/partials/code_block.html +++ b/layouts/partials/code_block.html @@ -5,6 +5,11 @@ {{- $output_is := .Get "outputis" | default (.Get 1) -}} {{- $download_as := .Get "downloadas" -}} {{- $snippet := .Get "snippet" -}} +{{- $repo := .Get "repo" -}} + +{{- if not $repo }} + {{- $repo = "istio" }} +{{- end -}} {{- $expand_links := "true" -}} @@ -78,6 +83,9 @@ {{- if $output_is -}} {{- $attrs = printf "%sdata-outputis='%s' " $attrs $output_is -}} {{- end -}} +{{- if $expand_links -}} + {{- $attrs = printf "%sdata-repo='%s' " $attrs $repo -}} +{{- end -}} {{- $anchor := "" }} {{- if $url -}} @@ -91,7 +99,7 @@ {{- range $link := $links -}} {{- $target := trim $link "@" -}} {{- if gt (len $target) 0 -}} - {{- $anchor = printf "Zip%s" $branch $target $anchor -}} + {{- $anchor = printf "Zip%s" $repo $branch $target $anchor -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/src/ts/codeBlocks.ts b/src/ts/codeBlocks.ts index 172dc79d3b..e279d86093 100644 --- a/src/ts/codeBlocks.ts +++ b/src/ts/codeBlocks.ts @@ -259,7 +259,7 @@ function handleCodeBlocks() { if (cmd !== "") { if (code.dataset.expandlinks === "true") { - cmd = cmd.replace(/@(.*?)@/g, "$1"); + cmd = cmd.replace(/@(.*?)@/g, "$1"); } let html = "
" + cmd + "
";