1
0
mirror of https://github.com/kremalicious/blog.git synced 2025-01-03 18:35:07 +01:00

kremalicious as a service

- output all posts with all metadata as json
This commit is contained in:
Matthias Kretschmann 2016-05-02 01:05:53 +02:00
parent 7e27e9c67c
commit d504173527
Signed by: m
GPG Key ID: BD3C1F3EDD7831FC
5 changed files with 37 additions and 2 deletions

View File

@ -73,7 +73,7 @@ var Search = (function(w, d) {
SimpleJekyllSearch({
searchInput: document.getElementById('search-input'),
resultsContainer: document.getElementById('search-results'),
json: '/search.json',
json: '/api/search.json',
searchResultTemplate: '<a class="search-link" href="{url}">{title}</a>',
fuzzy: false
});

22
_src/api/posts.json Normal file
View File

@ -0,0 +1,22 @@
---
layout: null
---
[
{% for post in site.posts %}
{
"title" : {{ post.title | titlecase | jsonify }},
"excerpt" : {{ post.excerpt | jsonify }},
"category" : "{{ post.categories | join: ', ' }}",
"tag" : "{{ post.tags | join: ', ' }}",
"url" : "{{ site.url }}{{ post.url }}",
"date" : "{{ post.date }}",
"content" : {{ post.content | jsonify }},
"image" : "{{ post.image }}",
"author" : "{{ post.author }}",
"layout" : "{{ post.layout }}",
"id" : "{{ post.id }}",
"path" : "{{ post.path }}",
"download" : "{{ post.download }}"
} {% unless forloop.last %},{% endunless %}
{% endfor %}
]

View File

@ -5,11 +5,13 @@ layout: null
{% for post in site.posts %}
{
"title" : "{{ post.title | strip_html | strip_newlines | titlecase }}",
"excerpt" : "{{ post.excerpt | strip_html | strip_newlines }}",
"category" : "{{ post.categories | join: ', ' }}",
"tag" : "{{ post.tags | join: ', ' }}",
"url" : "{{ site.url }}{{ post.url }}",
"date" : "{{ post.date }}",
"content" : "{{ post.content | strip_html | strip_newlines | escape }}"
"image" : "{{ post.image }}",
"content" : "{{ post.content | strip_html | strip_newlines | xml_escape }}"
} {% unless forloop.last %},{% endunless %}
{% endfor %}
]

10
_src/api/site.json Normal file
View File

@ -0,0 +1,10 @@
---
layout: null
---
[
{
"name" : "{{ site.name }}",
"description" : "{{ site.description | xml_escape }}",
"url" : "{{ site.url }}"
}
]

View File

@ -6,5 +6,6 @@ Disallow: /search/
Disallow: /page/
Disallow: /*/page/
Disallow: /tag/
Disallow: /api/
Sitemap: {{ site.url }}/sitemap.xml