Last active
August 29, 2015 14:14
-
-
Save kindfulkirby/51c6ff2ca685ebe95189 to your computer and use it in GitHub Desktop.
gitit: content.st template that automatically adds metadata
This file contains hidden or 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
| <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> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.