1
Fork 0

build a fulltext-searchable databose for the blog

This commit is contained in:
Jan-Erik Rediger 2022-04-22 22:44:09 +02:00
parent 9dcb4e9b14
commit 998794db4a
4 changed files with 34 additions and 2 deletions

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
_site
.rake_tasks~
blog.db

View file

@ -1,5 +1,6 @@
SOURCE = /home/jer/git/fnordig.de/_site/
DEST = /var/www/sites/fnordig.de/
DATABASE_PATH = blog.db
default:
rm -rf _site
@ -18,10 +19,14 @@ serve: build
cd _site && http
.PHONY: serve
deploy: clean build
deploy: clean build index
rsync -va --delete $(SOURCE) $(DEST)
.PHONY: deploy
index:
DATABASE_PATH="$(DATABASE_PATH)" ./index.sh
.PHONY: index
clean:
cobalt clean
.PHONY: clean

View file

@ -24,6 +24,8 @@ ignore:
- ext/
- README.md
- Makefile
- index.sh
- blog.db
syntax_highlight:
theme: "InspiredGitHub"
assets:

25
index.sh Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
set -e
DATABASE_PATH="${DATABASE_PATH:-blog.db}"
sqlite3 -batch -bail "$DATABASE_PATH" "
CREATE TABLE IF NOT EXISTS [posts] (
[_id] TEXT PRIMARY KEY,
[_path] TEXT,
[text] TEXT,
[html] TEXT,
[permalink] TEXT,
[title] TEXT,
[published_date] TEXT,
[layout] TEXT,
[data] TEXT,
[excerpt] TEXT
);
PRAGMA journal_mode = WAL;
PRAGMA foreign_keys = ON;
" >/dev/null
markdown-to-sqlite "$DATABASE_PATH" posts _posts/*
sqlite-utils enable-fts --fts5 "$DATABASE_PATH" posts title text 2>/dev/null || true
sqlite-utils rebuild-fts "$DATABASE_PATH" posts