Created
January 3, 2016 07:14
-
-
Save deptno/cd1d56b0f895b6cf502c to your computer and use it in GitHub Desktop.
jekyll snippet for atom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!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); | |
}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!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