Cleanup index

This commit is contained in:
Charlotte Allen 2020-07-22 18:53:25 -07:00
parent 0674314e0d
commit 462fef7cf6
1 changed files with 6 additions and 5 deletions

View File

@ -1,16 +1,17 @@
(ns shapey-shifty.index.index
(:require [clucy.core :as clucy]
[duratom.core :as dur]
[shapey-shifty.posts.posts-io :as post-io]))
(:require
[clojure.spec.alpha :as s]
[duratom.core :as dur]
[shapey-shifty.posts.posts-io :as post-io]))
(def index-path (atom "resources/index"))
(s/def ::index (s/keys :req [::filename ::key ::created-date ::stub]))
(defn create-index [index-path]
(let [index (dur/duratom :local-file :file-path index-path :init [])]
index))
(def post-index (clucy/disk-index @index-path))
(defn add-post-to-index [index post]
(let [metadata (dissoc post :content)]
(if-let [existing-post (empty (filter #(= (:key %) (:key post)) index))]