Href pdf link changes depending on URL

hello,I am working on a Hugo site and i need some help.

i have files that i have generated using pandoc/latex. The pdf files version of the website is located in a folder that says PDFs.

i want the html href to populate itself with the matching pdf file when “click to view pdf” is linked.

how would i do this in Javascript?

url: manual/company/culture/? file name/url when pdf is loaded :manual/company/culture/privacy-policy-index.md.tex.pdf

The file structure is: ​

Content/GeneratedFiles->LatexFiles
​PdfFiles
​generatepdf.js

You can use a page bundle/page resources for this (Page Resources | Hugo). From the ‘.Page.Resources’ variable you can get the URL of the first PDF in that specific folder and put it in the href. You do not need (or can do this with) javascript.

It looks like this:

<a href="{{ (.Page.Resources.GetMatch "**.pdf").RelPermalink }}">click to view pdf</a>