Skip to content
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

Modify refs text presentation logic #35

Open
eastarpen opened this issue Nov 13, 2022 · 2 comments
Open

Modify refs text presentation logic #35

eastarpen opened this issue Nov 13, 2022 · 2 comments

Comments

@eastarpen
Copy link

eastarpen commented Nov 13, 2022

current logic looks strange when display long link

e.g.

markdown content

---
title: "test"
refs:
  - name: long url test
    link: https://github.com/Ice-Hazymoon/hugo-theme-luna/blob/abadd6cbef141aaa99d2fa6f5d012e11c7112347/layouts/partials/article/components/refs.html#L9
  - name: short url
    link: https://google.com
  - link: http://link-without-name-set
---

official version

image

my version

image

code changed

only changed this line
>{{- if $ref.name -}}{{- $ref.name -}}{{- else -}}{{- $ref.link -}}{{- end -}}</a

whole refs.html

{{- if .Params.refs -}}
    <div class="w-full overflow-x-hidden border-t border-b bg-gray-100 bg-opacity-80 p-6 dark:border-darkBorder dark:bg-darkBgAccent md:px-10">
        <div class="mb-2 inline-block border-b-2 border-text pb-1 text-base">{{- T "post.refs" -}}</div>
        <div class="">
            {{- range $index, $ref := .Params.refs -}}
                <div class="overflow-hidden text-ellipsis whitespace-nowrap text-sm leading-loose">
                    <span>[{{- add $index 1 -}}] </span>
                    <a class="hover:underline" href="{{- or $ref.link "javascript:;" -}}" target="_blank" rel="noopener noreferrer"
                                                                                                          >{{- if $ref.name -}}{{- $ref.name -}}{{- else -}}{{- $ref.link -}}{{- end -}}</a
                    >
                </div>
            {{- end -}}
        </div>
    </div>
{{- end -}}
@Ice-Hazymoon
Copy link
Owner

Sorry, I don't understand what you are trying to achieve

@eastarpen
Copy link
Author

Sorry, I don't understand what you are trying to achieve

Sorry, it was descriped in more detail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants