-
Notifications
You must be signed in to change notification settings - Fork 4
Sitemap
The sitemap is the spine of the Frontman application. It holds every page of your site.
The sitemap is a SitemapTree
, and every node on the sitemap is a SitemapTree
as well.
A SitemapTree
can have many SitemapTree
s, and one or zero Resource
s.
Consider a site with the following pages:
/about/people/
/about/people/idris/
/about/people/naomi/
The node for /about/
contains one SitemapTree
(/about/people/
) and no Resource
, because there is no page at /about/
.
The node for /about/people/
contains a Resource
(the page itself), and two SitemapTree
s (/about/people/idris/
and /about/people/naomi/
).
There are two ways to access a node from the sitemap:
-
At the class level, Frontman has a static hash of URLs and their associated
SitemapTree
s. This access level is useful when trying to access a URL directly, regardless of whatSitemapTree
the current page belongs to.sitemap = Frontman::App.instance.sitemap_tree.from_url('/about/')
-
At the instance level, Frontman provides a child property that lets you traverse the entire hierarchy of a specific
SitemapTree
. This access level is useful when you want to render a set of nodes belonging to a specificSitemapTree
.current_tree.children.each do |child| puts child.resource.path end