Open jongacnik opened 6 years ago
that’s interesting. how does this work if we’re wanting to check global vs. local? for example page('child-page-example')
vs. page('/root-page-example')
.
Not sure what you mean by global vs local? I guess another way to phrase what I mean here is maybe it's best not to do anything fancy when calling page()
. Like, under the hood it could be as simple as:
function page (key) {
key = key || (state.href || '/')
this._value = state.content[key]
return this
}
Doing it this way might reduce complexity, in that it doesn't impose any restrictions on how your state is structured—all you have to do is pass in a key. That could be 'page-slug'
or '/page-slug'
or 'GLOBAL'
or whatever key you want.
ah word, i meant root or relative, i guess. i think you’re right in that now we no longer have to compare against a pages
object, so we can do something as simple as what you’re saying, which is sick.
Potentially allow lookups for keys not formatted like a path. This is mainly for allowing edge-case arbitrary content (I've been doing this), for example your content object could be shaped like:
Where
GLOBAL
is content that is general to the whole site. In your views you could then use something like: