mirror of
https://github.com/namibia/tips.git
synced 2024-12-23 10:38:58 +00:00
22 lines
749 B
JavaScript
22 lines
749 B
JavaScript
var tips = require('./tips.json');
|
|
// from https://gist.github.com/mathewbyrne/1280286
|
|
slugify = function(text){
|
|
return text.toString().toLowerCase()
|
|
.replace(/\s+/g, '-') // Replace spaces with -
|
|
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
|
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
|
.replace(/^-+/, '') // Trim - from start of text
|
|
.replace(/-+$/, ''); // Trim - from end of text
|
|
}
|
|
|
|
var render = function(data) {
|
|
var data = data.data;
|
|
|
|
var out = '* [' + data.title + '](https://github.com/git-tips/tips#' + slugify(data.title) + ')\n';
|
|
|
|
if (tips[tips.length -1].title === data.title) out = out + '\n';
|
|
return out;
|
|
};
|
|
|
|
module.exports = render;
|