~adnano/kiln-discuss

2 2

[not urgent] list pages of different directory

Details
Message ID
<CL08VCXG82CB.36N6AUAT0GLWO@quantum>
DKIM signature
pass
Download raw message
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
Details
Message ID
<CL15OM7MFRPJ.12IR361G8ELE@nitro>
In-Reply-To
<CL08VCXG82CB.36N6AUAT0GLWO@quantum> (view parent)
DKIM signature
pass
Download raw message
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 }}
Details
Message ID
<CL16RGH84UYH.198M4ZY1R9AHZ@quantum>
In-Reply-To
<CL15OM7MFRPJ.12IR361G8ELE@nitro> (view parent)
DKIM signature
pass
Download raw message
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
Reply to thread Export thread (mbox)