mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-02-24 17:42:43 +01:00
34 lines
732 B
JavaScript
34 lines
732 B
JavaScript
var React = require("react");
|
|
var Locale = require("../lib/locale");
|
|
var locale = new Locale();
|
|
|
|
|
|
module.exports = function generateBase(page, handler) {
|
|
|
|
// the basic class just has a title and basic content.
|
|
var ComponentClass = {
|
|
getDefaultProps: function() {
|
|
return {
|
|
page: page,
|
|
title: locale.getTitle(page),
|
|
handler: handler
|
|
};
|
|
},
|
|
|
|
render: function() {
|
|
return locale.getContent(page, this);
|
|
}
|
|
};
|
|
|
|
// if the content requires code bindings, ensure those exist:
|
|
if (handler) {
|
|
Object.keys(handler).forEach(key => {
|
|
ComponentClass[key] = handler[key];
|
|
});
|
|
}
|
|
|
|
// then build the actual React class
|
|
return React.createClass(ComponentClass);
|
|
|
|
};
|