bowman2001 / perplex

A Hugo theme to publish technical content (docs, news, blog, articles)
https://perplex.desider.at
Apache License 2.0
27 stars 11 forks source link

render-link broken for non-page links (e.g. PDF in page or global assets) #141

Closed danielfdickinson closed 8 months ago

danielfdickinson commented 8 months ago

In this line:

https://github.com/bowman2001/perplex/blob/22e538c5f69e0d207d2fa4eeaf6f0887a456601d/layouts/_default/_markup/render-link.html#L130

($page.GetPage (strings.TrimRight "/" (relref $page . )))

is executed even for resources that aren't pages (such as a PDF). relref barfs on this:

ERROR [en] REF_NOT_FOUND: Ref "2023-Oct-daniel-f-dickinson-resume.pdf" from page "daniel-f-dickinson-resume\\index.md": page not found

Removing just that bit gets the render-link working again.

bowman2001 commented 8 months ago

Thanks for the report. At first sight, I suspect that all arguments for the or operator are always evaluated even if the first ones are already true. Which is not a problem with existing pages but obviously with files.

I’m gonna look into this next week, probably. In the meantime, setting refLinksErrorLevel: warning could maybe allow you at least to build.

danielfdickinson commented 8 months ago

Thank you for that (and hope you are doing well in what for my area is a holiday season). FYI, I copied the layout and removed the offending bit (it's executed when the resource is not a page resource (so the first two bits are false) but fails because of the fact it is not a 'page'; IIRC ref and relref only apply to pages, not to arbitrary files) and have the site building.

I have a few more warts I've discovered while convert my (not yet published with Perplex, but the WIP repo is at https://gitlab.com/danielfdickinson/pp-danielfdickinson) and plan to report. Trying to get the site converted and live first though.

bowman2001 commented 8 months ago

My first impression has been false. The way in which I used the relref method was a conceptual mistake and I will get rid of it as you proposed. The link documentation will be updated accordingly.

bowman2001 commented 8 months ago

I cloned your repository but I couldn’t generate your site. The culprits are image files which do not contain actual images but placeholder text. Halloween-1998-wide.png for example:

version https://git-lfs.github.com/spec/v1
oid sha256:48ef64bdf1e6978e67e3c52c641c4bd00f8387e4a4c6b32e0d8b28a1943aa922
size 121496
danielfdickinson commented 8 months ago

Ah, yes, I use Git LFS. You would install Git-LFS and execute

git lfs install --local
git lfs checkout

Once LFS is on your system you shouldn't need to do those steps with new checkouts.