- using node v.6
- run command
npm install
oryarn
to install packages - add config to your .env file
COOKIE_SECRET=
CLOUDINARY_URL=
MANDRILL_API_KEY=
MONGO_URI=
- run command
node keystone
oryarn start
to start project. TEDxKasetsartU website should open in http://localhost:3000.
Write your app wide constants in /constants.js
for easy use across the app.
var consts = require('../constants.js');
console.log(consts.locales);
There's couple of gotchas with the internationalization of TEDxKasetsartU website.
Used locales and e.g. name of the cookie containing locale are stored in constants.js
.
Locale files are located in locales/
. They're somewhat autogenerated so don't touch anything else than the translated string values.
Use __('view_id_here.string_id_here')
for all hard coded strings. See templates/views/index.jade
for further reference.
Example:
p
| !{__('index.new_website', {keystoneLink: '<a href="http://keystonejs.com" target="_blank">KeystoneJS</a>'})}
Creating and using translatable fields for dynamic content is possible with createField
, combineFields
and getField
.
var keystone = require('keystone');
const { createField, combineFields } = require('keystone-translated-fields');
const locales = require('../constants').locales;
const Types = keystone.Field.Types;
const Speaker = new keystone.List('Speaker', {
map: {
name: 'title',
},
singular: 'Speaker',
plural: 'Speakers',
autokey: {
path: 'slug',
from: 'title',
unique: true,
},
});
Speaker.add(combineFields([
{ title: { type: String, required: true } },
{ name: { type: String } },
{ desc: { type: Types.Html, wysiwyg: true, height: 300 } },
{ image: { type: Types.CloudinaryImage } },
createField('about', { type: String }, locales),
]));
Speaker.register();
h3 #{getField(speaker, 'title', locale)}
if speaker.desc
!= speaker.desc
p #{getField(speaker, 'about', locale)}
Follow git flow.