will
1
Code: GitHub - willfaught/paige at ff21e2480a94fa6df7a591dd47e08495133f2ab1
Run and view: http://localhost:1313/shortcodes/gallery/
The images work.
Apply this diff:
diff --git a/layouts/partials/paige/resource.html b/layouts/partials/paige/resource.html
index 0ad1101..0307a67 100644
--- a/layouts/partials/paige/resource.html
+++ b/layouts/partials/paige/resource.html
@@ -16,10 +16,10 @@
{{ end }}
{{ if and (not $result) $page }}
- {{ with $page.Resources.GetMatch $url }}
+ {{ with page.Resources.GetMatch $url }}
{{ $result = . }}
{{ else }}
- {{ with $page.Resources.Get $url }}
+ {{ with page.Resources.Get $url }}
{{ $result = . }}
{{ end }}
{{ end }}
Refresh http://localhost:1313/shortcodes/gallery/
The images are broken.
the page
function always refer to current/top-most context page being executed.
based on this code, i suspect the Page
object passed via $params.page
is different than current Page
being executed.
2 Likes
will
3
That would mean that the images would be wrong when using $page instead of page, but theyβre correct.
I think you misunderstood @pamubayβs explanation.
The page
function gives you access to the top-most page context.
content structure
content/
βββ posts/
β βββ post-1.md
β βββ post-2.md
β βββ post-3.md
βββ _index.md
layouts/home.html
{{ range site.Sections }}
{{ range .Pages }}
{{ page.Title }}
{{ end }}
{{ end }}
This will print the title of content/_index.md (the home page) three times.
If youβre going to use the global page
function, you need to know where you started.
And I can assure you that page.Resources.Somemethod
works just fine.
3 Likes
will
5
Ah, I see. OK, I understand whatβs happening now. Thanks to you both!
Why was βpageβ designed to work that way instead of the way I expected? Whatβs the useful scenario in that case?
system
Closed
6
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.