Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

RFC: Expand features of Blog #209

Open
r3wt opened this issue Jun 12, 2016 · 0 comments
Open

RFC: Expand features of Blog #209

r3wt opened this issue Jun 12, 2016 · 0 comments

Comments

@r3wt
Copy link
Contributor

r3wt commented Jun 12, 2016

The current Blog shipping with keystone is very basic. In order to make it a viable alternative to that one popular platform (which shall not be named), the features of the default blog need to be expanded.

Proposed new features:

  • Search
  • Tags
  • Archive
  • Author Biography/Profile
  • Comments
  • Statistics Counters

Considerations:

Generating Statistics and Computing a list of available tags on the front end would hinder performance. In the case of tags, we can use a simple model to store this data with schema.post('save') hooks on our models that will affect said lists. in this way we move the perf hit to place where the change occurs, keeping the front end light. statistics counters, such as the number of views and number of comments can reside right on the Post model and be updated as changes occur vary easily.

here is the proposed model i would use to store any aggregate data. really its just a list of string arrays. super duper easy and flexible:

var keystone = require('keystone');
var Types = keystone.Field.Types;

/**
 * AggregateList Model
 * ==================
 */
var AggregateList = new keystone.List('AggregateList', {
    map: { name: 'title' },
    autokey: { path: 'slug', from: 'title', unique: true, index: true},
    hidden: true
});

AggregateList.add({
    title: { type: String },
    items: { type: Types.TextArray }
});

AggregateList.register();

Notice the usage of slugs here. the slugs are used to retrieve the list. for example, to retrieve the list of all tags:

view.on('init',function(next) {
    keystone.list('Aggregate List').model.findOne({slug:'blog-tag-aggregator'}).exec(function(err,results){
        locals.tags = results.items;
        next(err);
    });
});

In my opinion to keep this model flexible it would be advantageous to use slugs instead of relationships.

As you might imagine, i've already got most of the code for this, including the templates for twig. We would need some help on the templates for : nunjucks, handlebars, and possibly jade. Any other help, comments or ideas is greatly appreciated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant