i want this kind of file structure:
- index.gmi
- blog/
- blogpost1.gmi
- blogpost2.gmi
- blogpost3.gmi
- blogpost4.gmi
...
how can i make it, so that the blog posts are listed in index.gmi?
i circumvented this by ranging over the .Dirs, and checking if .Path is
equal to "/blog/", then ranging over the .Pages, but is there a better way?
- w1ke from w1ke.cz
On Sun Jun 26, 2022 at 1:33 PM EDT, w1ke wrote:
> i circumvented this by ranging over the .Dirs, and checking if .Path is> equal to "/blog/", then ranging over the .Pages, but is there a better way?
Previously, there was not a better way to do this. However, I've just
pushed a commit which adds a new .GetPage function to pages which can be
used to retrieve a page by its path.
You can use it like so:
{{ with .GetPage "blog" }}
{{ range .Pages }}
...
{{ end }}
{{end}}
You can also retrieve pages relative to the site root directory by using
site.Root.GetPage:
{{ with site.Root.GetPage "/blog" }}
...
{{ end }}
On Mon Jun 27, 2022 at 9:16 PM CEST, Adnan Maolood wrote:
> Previously, there was not a better way to do this. However, I've just> pushed a commit which adds a new .GetPage function to pages which can be> used to retrieve a page by its path.
thanks! .GetPage works perfectly!
- w1ke from w1ke.cz