-
-
Notifications
You must be signed in to change notification settings - Fork 355
feat(codeblock): add full URL support #820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for hugo-hextra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly a fixed version.
|
I think your PR must reference the issue #801 instead of the discussion #799. The comments inside a PR description cannot automatically close a discussion, they can only close an issue or another PR. The title can also be improved: For consistency, I recommend using a local variable: diff --git i/layouts/_partials/components/codeblock.html w/layouts/_partials/components/codeblock.html
index 857b925..43afe2e 100644
--- i/layouts/_partials/components/codeblock.html
+++ w/layouts/_partials/components/codeblock.html
@@ -1,5 +1,6 @@
{{ $filename := .filename | default "" -}}
{{ $base_url := .base_url | default "" -}}
+{{ $full_url := .full_url | default "" -}}
{{ $lang := .lang | default "" }}
{{ $content := .content }}
{{ $options := .options | default (dict) }}
@@ -13,8 +14,8 @@
{{- $file_url := $filename -}} <!-- default to just filename -->
- {{- with .full_url -}}
- {{- $file_url = . -}}
+ {{- if $full_url -}}
+ {{- $file_url = $full_url -}}
{{- else if $base_url -}}
{{- $file_url = urls.JoinPath $base_url $filename -}}
{{- end -}} |
|
@wharris23 could you update the PR based on the above feedback? |
|
@imfing Yes, I apologize for the delay. I am working on the PR today and tomorrow. |
no worries take your time |
Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
|
@imfing I believe all the checks pass now. Please let me know if you think this is good or if I can improve it. |
|
I think you missed this remark: For consistency, I recommend using a local variable: diff --git i/layouts/_partials/components/codeblock.html w/layouts/_partials/components/codeblock.html
index 857b925..43afe2e 100644
--- i/layouts/_partials/components/codeblock.html
+++ w/layouts/_partials/components/codeblock.html
@@ -1,5 +1,6 @@
{{ $filename := .filename | default "" -}}
{{ $base_url := .base_url | default "" -}}
+{{ $full_url := .full_url | default "" -}}
{{ $lang := .lang | default "" }}
{{ $content := .content }}
{{ $options := .options | default (dict) }}
@@ -13,8 +14,8 @@
{{- $file_url := $filename -}} <!-- default to just filename -->
- {{- if .full_url -}}
- {{- $file_url = . -}}
+ {{- if $full_url -}}
+ {{- $file_url = $full_url -}}
{{- else if $base_url -}}
{{- $file_url = urls.JoinPath $base_url $filename -}}
{{- end -}} |
template comments instead of HTML comments Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
| {{- /* Default to just filename */ -}} | ||
| {{- $file_url := $filename -}} | ||
|
|
||
| {{- if .full_url -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full_url is ignored when $base_url is empty, please pay attention to line 9
Summary
This PR adds support for using a
full_urlwhen linking files in code blocks.Changes
full_urlis provided, it is used directly.base_url + filenameor justfilename.This keeps the old behavior while allowing more flexibility for cases where file URLs don’t follow the standard format.
Closes #801