Add character names to the end of their URL's

Closes #21, makes links to characters human readable
This commit is contained in:
Stefan Zermatten
2017-07-13 13:14:04 +02:00
parent 089feae26f
commit 3227cd0934
9 changed files with 59 additions and 9 deletions

View File

@@ -125,7 +125,7 @@ Migrations.add({
}
});
var effect = Effects.findOne({
charId: char._id, name: "Natural Carrying Capacity"
charId: char._id, name: "Natural Carrying Capacity",
});
if (effect) return;
Effects.insert({
@@ -141,7 +141,7 @@ Migrations.add({
},
});
effect = Effects.findOne({
charId: char._id, name: "Natural Carrying Capacity"
charId: char._id, name: "Natural Carrying Capacity",
});
if (!effect) throw "Carry capacity effect should be set by now."
});
@@ -150,3 +150,19 @@ Migrations.add({
return;
},
});
Migrations.add({
version: 5,
name: "Gives all characters a URL name",
up: function() {
//update characters
Characters.find({}).forEach(function(char){
if (char.urlName) return;
var urlName = getSlug(char.name, {maintainCase: true});
Characters.update(char._id, {$set: {urlName}});
});
},
down: function(){
return;
},
});

View File

@@ -15,6 +15,7 @@ Meteor.publish("characterList", function(){
{
fields: {
name: 1,
urlName: 1,
race: 1,
alignment: 1,
gender: 1,