Created
June 4, 2016 16:32
-
-
Save mrsimonemms/e8861de9674a15ca1707bd6f6dcd724f to your computer and use it in GitHub Desktop.
Running AngularJS on Jekyll
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
--- | |
title: Template | |
comments: true | |
tags: | |
- tag1 | |
- tag2 | |
--- | |
This is my template file |
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
permalink: :year-:month-:day-:title |
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
angular | |
.module("app") | |
.factory("engine", function ($http) { | |
return { | |
getPosts: function () { | |
return $http.get("/api/posts/list.json") | |
.then(function (posts) { | |
return posts.map(function (post) { | |
/* Convert date into Date */ | |
post.date = new Date(post.date); | |
/* Remove starting slash from URL */ | |
post.url = post.url.replace(/^\//, ""); | |
return post; | |
}); | |
}); | |
} | |
}; | |
}); |
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
--- | |
--- | |
[ | |
{% for post in site.posts %} | |
{ | |
"title" : {{ post.title | jsonify }}, | |
"category" : {{ post.category | jsonify }}, | |
"tags" : {{ post.tags | jsonify }}, | |
"url" : {{ post.url | prepend: site.baseurl | jsonify }}, | |
"date" : "{{ post.date | date: '%Y-%m-%dT00:00:00Z' }}", | |
"excerpt" : {{ post.excerpt | jsonify }}, | |
"content" : {{ post.content | jsonify }}, | |
"comments" : {{ post.comments | jsonify }} | |
} {% unless forloop.last %},{% endunless %} | |
{% endfor %} | |
] |
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
. | |
├── _config.yml // Jekyll config | |
├── bower.json // Optional, if using bower | |
├── index.html | |
├── package.json // Optional, if using npm | |
├── _posts | |
| └── // Jekyll posts | |
├── _sass | |
| └── // SASS files for Jekyll to generate | |
├── api | |
| └── // Jekyll generated JSON files for Angular to consume | |
├── bower_components | |
| └── // Bower depedencies | |
├── css | |
| └── main.css | |
├── img | |
| └── // Image files | |
├── js | |
| └── // Angular app | |
├── node_modules | |
| └── // npm dependencies | |
└── views | |
└── // Angular view files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment