You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CM2] model.match(),create() rootContext and fixes
Some ideas in this one:
Match & Create
==============
Each model has a method named 'match' which returns whether or not a
node satisfies the model's fsNode requirements. And they have a 'create'
method to turn a node into a content-model.
So, e.g., a collection calls category.match(node) in a node traversal,
and then calls category.create(node) if the former returns true.
Each model configures its matchers mostly based on the settings it
receives.
Benefits:
- Prevents the duplicaiton of functions like 'isPost', 'isPostIndexFile'
etc.
- Models look similar in shape to each other and to root (countdown to
class Model {})
- Post index files can now be named with the entryAlias. e.g. demo.md,
episode.md, article.md
- Same goes for categories. Whatever alias works.
Root context
============
ContentModel2 has now a context object which is passed down throughout
the tree, just like a collection context.
Benefits:
- No more reliance on settings.out and settings.permalinkPrefix in
models. So, permalinks and outputPaths are computed completely by a
cascade of contexts.
- This inspires a further improvement of automating that computation by
introducing a context depth-level. Each model would rely on the
context that is closest to itself, without necessarily recognizing
where it comes from. But to not complicate the templates, some magic
should follow it either in rendering phase or in the form of template
helpers. {{context.category.permalink}} is too tasty to give up on.
- It also means simpler/less settings for initializing models.
Some fixes
==========
- Category index
- Tags
0 commit comments