This may not be the proper forum for this, but I'm trying to incorporate
Lunrjs search into my static sites.
Years ago, Christopher Stone provided me with a wonderful little script
that scans project files and generates an HTML list of the titles, with
href links.
This is a bit more ambitious because instead of looking for single-line
content, I want to grab everything that is inside the <article> tags --
along with the title tag content and the URL -- and create a JSON file that
I can then process through Lunrjs for site search.
Here's what Christopher provided me for the previous utility.
```
# generate a TOC of the site files
# thank you, Christopher Stone
cd /Users/greg/Sites/site/ || exit
grep --include="*.html" -Eir "<title>.+</title>" . \
| sed -E '
s!^\.!<li><a href="!
s!:[[:space:]]*<title>[[:space:]]?!">!
s!</title>!</a></li>!
' \
| sort \
| bbedit
```
The final file would have the format:
```
{
"docs": [
{
"location": "#welcome",
"text": "Full documentation.",
"title": "Welcome to my docs"
},
{
"location": "#about-this-site",
"text": "This is to augment my other site.",
"title": "About this site"
},
]
}
```
Any thoughts or suggestions are appreciated.
--
This is the BBEdit Talk public discussion group. If you have a feature request
or need technical support, please email "[email protected]" rather than
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/7d4bb224-49f2-4127-b1bd-33ec624ac08bn%40googlegroups.com.