hugo-theme-learn icon indicating copy to clipboard operation
hugo-theme-learn copied to clipboard

Attachments with multilingual configuration missing subdir

Open sebastianschauenburg opened this issue 4 years ago • 5 comments

According to the documentation ( https://learn.netlify.com/en/shortcodes/attachments/ ) it should be possible to add attachments. When I add a subdirectory called _index.files, the attachments are displayed correctly (yay), but when I click on them, they are missing the subdirectory of the language, which results in a 404. I've tried renaming the directory to add "en" (english language code) to the directory, but it didn't help.

So I expected a http://base.url.ext/en/_index.files/attachment.pdf URL (when clicking on the attachment) but got http://base.url.ext/_index.files/attachment.pdf instead, resulting in a 404.

What am I doing wrong here, or is this perhaps a bug? (perhaps related to this, the documentation states "Be aware that if you use a multilingual website, you will need to have as many folders as languages.")

Thanks for this great theme. I've been using it for documentation for a while and it's fantastic.

sebastianschauenburg avatar Mar 23 '20 07:03 sebastianschauenburg

The problem is here: https://github.com/matcornic/hugo-theme-learn/blob/master/layouts/shortcodes/attachments.html#L13

I'm not sure how it can be fixed. Maybe if there was a better way to get the full path of the current page

tarpdalton avatar Jun 01 '20 21:06 tarpdalton

I've got the same problem. the attachment-shortcut does not work for multi lingual projects with languages by folder... Will there be a fix?

content/de
content/en

and the attachement tries to access the folder:

\content\gs\zusatzmodule\gsmosquitto\test\files:

but it should be:

\content\de\gs\zusatzmodule\gsmosquitto\test\files:
\content\en\gs\zusatzmodule\gsmosquitto\test\files:

but maybe I want to show attachemnts of a totally different folder?

muffmolch avatar Jun 17 '20 13:06 muffmolch

i find a dirty way to get the path

{{ $raw_info := printf "%v" (os.Stat .File) }}
{{ $filename_string := index (findRE "filename:.* fs:" $raw_info) 0 }}
{{ $filename_string := strings.TrimLeft "filename:" $filename_string}}
{{ $filename := strings.TrimRight " fs:" $filename_string}}
{{ $filename }}

i do think it's a vulnerability, that os.Stat expose the absolute path of the file in filesystem.

maybe better use Page Bundle instead as https://github.com/matcornic/hugo-theme-learn/issues/100 described?

eZioPan avatar Oct 28 '20 09:10 eZioPan

Here are the docs for page resources/bundles. I think it could work https://gohugo.io/content-management/page-resources/

tarpdalton avatar Oct 28 '20 18:10 tarpdalton

@muffmolch: Fixed in McShelby/hugo-theme-relearn#105

McShelby avatar Sep 29 '21 12:09 McShelby