I am busy setting up search functionality for my site using lunr.js
. Searching works, but I would like to also index HTML files that I display via a shortcode.
Here is the content of my index.json
file:
[{{ range $index, $value := where .Site.Pages ".Params.exclude_search" "!=" true }}
{{ if $index }},{{ end }}
{
"url": "{{ .Permalink }}",
"title": "{{ .Title }}",
"body": {{ .Plain | plainify | jsonify }},
"excerpt": {{ .Summary | plainify | jsonify }},
"htmlbody": {{ .Params.htmlfile | plainify | jsonify }}
}
{{ end }}]
Some of my pages are using a shortcode that references an HTML file which is then displayed. I added a variable called htmlfile
to the front matter of a page that embeds an HTML file, which I then reference inside the index.json
file.
At the moment (obviously), the content of htmlbody
is the reference to the HTML file, rather than the content of that file. How would I go about parsing the content of the referenced HTML file and assigning that content to htmlbody
?
Thank you.
Marc.