Skip to content

Instantly share code, notes, and snippets.

@KyleMit
Created August 27, 2019 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KyleMit/1530a48f9ddc107ec25a9b87df8938c8 to your computer and use it in GitHub Desktop.
Save KyleMit/1530a48f9ddc107ec25a9b87df8938c8 to your computer and use it in GitHub Desktop.
title tags
about
post

My About Page

title tags
index
post

My Home Page

{
"name": "1ttyData",
"version": "1.0.0",
"description": "",
"author": "",
"license": "ISC",
"devDependencies": {
"@11ty/eleventy": "^0.9.0-beta.3"
}
}
class SearchIndex {
data() {
return {
// https://www.11ty.io/docs/languages/javascript/#permalinks
permalink: "/search2.json",
};
}
render(data) {
let search = data.collections.post.map(item => {
return {
url: item.url,
title: item.data.title,
text: item.data.templateContent
}
})
var stringify = JSON.stringify(search, null, 2)
return stringify;
}
}
module.exports = SearchIndex;
---
permalink: search.json
---
[
{%- for item in collections.post -%}
{
"url" : "{{ item.url }}",
"title" : "{{ item.data.title }}",
"text" : "{{ item.templateContent }}"
}{% if not loop.last %},{% else %}{%- endif -%}
{%- endfor -%}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment