Skip to content

Commit 18abaaf

Browse files
committed
attachments: fix incorrect links for defaultContentLanguageInSubdir=true matcornic#425
1 parent 838f13d commit 18abaaf

File tree

18 files changed

+99
-15
lines changed

18 files changed

+99
-15
lines changed

exampleSite/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ disableHugoGeneratorInject = true
124124

125125
[Languages.pir]
126126
title = "Cap'n Hugo Relearrrn Theme"
127-
weight = 1
127+
weight = 2
128128
languageName = "Arrr! ☠ Pirrrates ☠"
129129
landingPageName = "<i class='fas fa-home'></i> Arrr! Home"
130130

exampleSite/content/basics/migration/_index.en.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ This document shows you what's new in the latest release. For a detailed list of
1414

1515
---
1616

17-
## 5.9.0 (not yet released)
17+
## 5.9.0 (2022-12-23)
18+
19+
- {{% badge style="note" title=" " %}}Change{{% /badge %}} The required folder name for the [`attachments` shortcode]({{% relref "shortcodes/attachments" %}}) was changed for leaf bundles.
20+
21+
Previously, the attachments for leaf bundles in non-multilang setups were required to be in a `files` subdirectory. For page bundles and leaf bundles in multilang setups they were always required to be in a `_index.<LANGCODE>.files` or `index.<LANGCODE>.files` subdirectory accordingly.
22+
23+
This added unnessessary complexity. So attachments for leaf bundles in non-multilang setups can now also reside in a `index.files` directory. Although the old `files` directory is now deprecated, if both directories are present, only the old `files` directory will be used for compatiblity.
1824

1925
- {{% badge style="note" title=" " %}}Change{{% /badge %}} Absolute links prefixed with `http://` or `https://` are now opened in a separate browser tab.
2026

exampleSite/content/shortcodes/attachments.en.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,49 @@ While the examples are using shortcodes with named parameter you are free to als
3131
{{% /tab %}}
3232
{{< /tabs >}}
3333

34-
The shortcode lists files found in a specific folder.
34+
The shortcode lists files found in a specific folder. The name of the folder depends on your page type (either branch bundle, leaf bundle or page).
3535

36-
Currently, it supports two implementations for pages
37-
38-
1. If your page is a Markdown file, attachments must be placed in a folder named like your page and ending with `.files`.
36+
1. For simple pages, attachments must be placed in a folder named like your page and ending with `.files`.
3937

4038
> * content
4139
> * _index.md
4240
> * **page.files**
4341
> * attachment.pdf
4442
> * page.md
4543
46-
2. If your page is a folder, attachments must be placed in a nested `files` folder.
44+
2. If your page is a branch or leaf bundle, attachments must be placed in a nested `_index.files` or 'index.files' folder, accordingly.
45+
46+
For branch bundles:
4747

4848
> * content
4949
> * _index.md
5050
> * page
5151
> * index.md
52-
> * **files**
52+
> * **index.files**
5353
> * attachment.pdf
5454
55-
Be aware that if you use a multilingual website, you will need to have as many folders as languages.
55+
For leaf bundles:
56+
57+
> * content
58+
> * _index.md
59+
> * page
60+
> * _index.md
61+
> * **_index.files**
62+
> * attachment.pdf
63+
64+
Be aware that if you use a multilingual website, you will need to have as many folders as languages and the language code must be part of the folder name.
65+
66+
Eg. for a site in English and Piratish:
5667

68+
> * content
69+
> * _index.en.md
70+
> * _index.pir.md
71+
> * **page.en.files**
72+
> * attachment.pdf
73+
> * **page.pir.files**
74+
> * attachment.pdf
75+
> * page.en.md
76+
> * page.pir.md
5777
5878
### Parameter
5979

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
+++
2+
description = "Testing Attachments Shortcode"
3+
title = "Attachments Shortcode Test"
4+
+++
5+
6+
Our attachment shortcode is a source of pleasure...
7+
8+
{{%children containerstyle="div" style="h2" description="true" %}}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
+++
2+
description = "Test'n Attachments Shorrrtcode"
3+
title = "Attachments Shorrrtcode Test"
4+
+++
5+
{{< piratify >}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a small text
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
+++
2+
title = "Attachments Branch Test"
3+
+++
4+
5+
{{% attachments /%}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Harrr, nothn' to see herre
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
+++
2+
title = "Attachments Brrranch Test"
3+
+++
4+
5+
{{% attachments /%}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a small text

0 commit comments

Comments
 (0)