Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-path based keys #4

Open
jongacnik opened this issue Apr 19, 2018 · 3 comments
Open

Non-path based keys #4

jongacnik opened this issue Apr 19, 2018 · 3 comments
Labels
enhancement New feature or request

Comments

@jongacnik
Copy link
Collaborator

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:

{
  'GLOBAL': {},
  '/': {},
  '/projects': {},
  '/projects/a': {}
}

Where GLOBAL is content that is general to the whole site. In your views you could then use something like:

page('GLOBAL').value('title')
@jongacnik jongacnik added the enhancement New feature or request label Apr 19, 2018
@jongacnik jongacnik changed the title non-path based keys Non-path based keys Apr 19, 2018
@jondashkyle
Copy link
Owner

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').

@jongacnik
Copy link
Collaborator Author

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.

@jondashkyle
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants