Hi there,
(edit: you can ignore this post until I work seriously on it)
Hi there,
(edit: you can ignore this post until I work seriously on it)
You do not seem to be using the parameter you pass into your shortcode:
(edited, see below for a recent version)
Your code makes very little sense to me.
$page
to either the empty string or to a .Page
object.Resources.GetMatch
requires a string parameter, not a .Page
object.Perhaps posting a link to your repository generates better responses here
You are absolutely right, I’ll take time to drink a coffee and will update this post if I still can’t find my way,
Thanks @chrillek !
Ok I’ve got something better:
{{- $page := .Get "page" -}}
{{ with $page }}
{{ (site.GetPage $page).TableOfContents }}
{{ end }}
the only problem now is that anchors URLs do not contain the full path to the external page:
The generated URL for each of the external titles looks like #anchor
instead of foo/#anchor
The solution I’m finally using:
{{- $page := .Get "page" -}}
{{ with $page }}
{{- $toc := (site.GetPage $page).TableOfContents -}}
{{ replace $toc `href="#` (printf `href="%s#` (site.GetPage $page).RelPermalink) | safeHTML }}
{{ end }}
You might want to store the result of (siteGetPage $page).RelPermalink
in a variable and use that inside the loop. Old thing: Move invariants out of loops.
Related resources, for the record:
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.