Skip to content

Instantly share code, notes, and snippets.

@deptno
Created January 3, 2016 07:14
Show Gist options
  • Save deptno/cd1d56b0f895b6cf502c to your computer and use it in GitHub Desktop.
Save deptno/cd1d56b0f895b6cf502c to your computer and use it in GitHub Desktop.
jekyll snippet for atom
!function() {
var workspace = atom.workspace;
var editor = workspace.getActiveTextEditor();
var date = (new Date(Date.now() - (new Date()).getTimezoneOffset() * 60000)).toISOString().slice(0,-1);
var text = [
'---',
'layout: post',
'title: ',
'excerpt: ',
'category: draft',
'author_url: /author/deptno',
'author_avatar: deptno-yuri',
'show_avatar: true',
'show_related_posts: true',
'feature_image: ',
'square_related: ',
'read_time: 1',
'comments: true',
'date: '+date,
'modified: '+date,
'---',
''
].join('\n');
editor.setText(text);
}();
!function() {
var workspace = atom.workspace;
var editor = workspace.getActiveTextEditor();
var text = editor.getText();
var regexp = /modified: .*/;
var founds = regexp.exec(text)
if (founds.length) {
var timeString = 'modified: ' + (new Date(Date.now() - (new Date()).getTimezoneOffset() * 60000)).toISOString().slice(0,-1);
console.log(timeString);
editor.setText(text.replace(founds[0], timeString));
} else {
console.log('founds.length: ' + founds.length);
}
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment