Open jondashkyle opened 6 years ago
Yea I was already thinking about this! Using url
feels really fragile and would much rather use key. I could see this working a couple ways. Demonstrating here with v psuedo code (imagine this
making sense in the context of the class):
_key
, in addition to _state
and _value
function page (key) {
this._key = key
this._value = this._state[key]
}
function children () {
var children = // regex using `this._key`
return children
}
function page (key) {
this._value = {
[key]: this._state[key]
}
}
function children () {
var key = Object.keys(this._value)[0]
var children = // regex using `key`
return children
}
something closer to the second option might be right, as i’m unsure how we’d handle that with a heavy chain such as:
page('/example').pages().sortBy('date', 'asc').first().find('wtf').v()
that Object.keys
solution seems like a bit of a hack, in that if you run children
when not on a page you might get some wild results, but that might be nbd.
The new
pages
regex checks against a key namedurl
to find children. This is fine when using with something likehypha
as it defines aurl
key in each page object. Would be cool to fallback to the page key name somehow if that url is unavailable, but gets a little tricky with howvalue
is continually set as methods are called with function chainability.Anyway, quick though and dropping here to think about later.