diff --git a/exampleSite/content/docs/guide/syntax-highlighting.md b/exampleSite/content/docs/guide/syntax-highlighting.md index 45cc50c5..42c5f617 100644 --- a/exampleSite/content/docs/guide/syntax-highlighting.md +++ b/exampleSite/content/docs/guide/syntax-highlighting.md @@ -40,6 +40,22 @@ def say_hello(): print("Hello!") ``` +### Link to File + +You can use the `base_url` attribute to provide a base URL that will be combined with the file name to generate a link. + +The file name can include a relative path if it specifies the file's location within the base path. + +````markdown {filename="Markdown"} +```go {base_url="https://github.com/imfing/hextra/blob/main/",filename="exampleSite/hugo.work"} +go 1.20 +``` +```` + +```go {base_url="https://github.com/imfing/hextra/blob/main/",filename="exampleSite/hugo.work"} +go 1.20 +``` + ### Line Numbers To set line numbers, set attribute `linenos` to `table` and optionally set `linenostart` to the starting line number: diff --git a/layouts/_default/_markup/render-codeblock.html b/layouts/_default/_markup/render-codeblock.html index 31b3c258..fe2df204 100644 --- a/layouts/_default/_markup/render-codeblock.html +++ b/layouts/_default/_markup/render-codeblock.html @@ -1,12 +1,13 @@ {{- $class := .Attributes.class | default "" -}} {{- $filename := .Attributes.filename | default "" -}} +{{- $base_url := .Attributes.base_url | default "" -}} {{- $lang := .Attributes.lang | default .Type -}}