Skip to content

Instantly share code, notes, and snippets.

@kindfulkirby
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save kindfulkirby/51c6ff2ca685ebe95189 to your computer and use it in GitHub Desktop.

Select an option

Save kindfulkirby/51c6ff2ca685ebe95189 to your computer and use it in GitHub Desktop.
gitit: content.st template that automatically adds metadata
<div id="content">
$if(revision)$
<h2 class="revision">Revision $revision$</h2>
$endif$
<h1 class="pageTitle"><a href="$base$$pageUrl$">$pagetitle$</a></h1>
$if(messages)$
$messages()$
$endif$
$content$
<script type="text/javascript">
textbox = document.getElementById("editedText");
if(textbox) {
if(textbox.value == '') {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
mm='0'+mm
}
today = yyyy+'-'+mm+'-'+dd;
textbox.value += '---\\\n' +
'format: markdown\\\n' +
'date: ' + today + '\\\n' +
'toc: no\\\n' +
'categories: \\\n' +
'tags: \\\n' +
'title: ' + decodeURIComponent(document.URL.split('/').pop()) + '\\\n' +
'...'
}
}
</script>
</div>
@kindfulkirby
Copy link
Author

The date: and tags: metadata are (afaik) ignored by gitit, but they can be useful if you - like me - want to feed these file to a static site generator (e.g. Jekyll) with a git hook. More on that later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment