scrape old snippets
This commit is contained in:
parent
bcf8313a4b
commit
700710df56
2 changed files with 31 additions and 2 deletions
8
deps.edn
8
deps.edn
|
|
@ -8,11 +8,15 @@
|
|||
com.xtdb/xtdb-api {:mvn/version "2.0.0-beta9"}
|
||||
com.github.seancorfield/next.jdbc {:mvn/version "1.3.1002"}
|
||||
org.postgresql/postgresql {:mvn/version "42.7.6"}
|
||||
frontmatter/frontmatter {:mvn/version "0.0.1"}
|
||||
|
||||
;; json decoding
|
||||
;; schema validation
|
||||
metosin/malli {:mvn/version "0.18.0"}
|
||||
|
||||
;; json decoding
|
||||
metosin/muuntaja {:mvn/version "0.6.11"}
|
||||
|
||||
;; routing:
|
||||
;; routing:
|
||||
metosin/reitit {:mvn/version "0.9.1"}
|
||||
|
||||
;; convenient package of "default" middleware:
|
||||
|
|
|
|||
25
src/snippets/backfill.clj
Normal file
25
src/snippets/backfill.clj
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
(ns snippets.backfill
|
||||
(:require
|
||||
[clojure.java.io :as io]
|
||||
[clojure.pprint :as pprint]
|
||||
[clojure.string :as str]
|
||||
[frontmatter.core :as fm]))
|
||||
|
||||
(defn scrape-files []
|
||||
(let [dir "./old_snippets"]
|
||||
(->> (io/file dir)
|
||||
(.listFiles)
|
||||
(map #(.getName %))
|
||||
(map #(hash-map :slug (first (str/split % #"\.")) :full-path (str dir "/" %)))
|
||||
;; (map #(fm/parse (:full-path %))))))
|
||||
(map #(let [{frontmatter :frontmatter body :body} (fm/parse (:full-path %))]
|
||||
(assoc %
|
||||
:title (:title frontmatter)
|
||||
:pub-date (:date frontmatter)
|
||||
:markdown body
|
||||
:scraped true
|
||||
:tags (:snippet_types frontmatter))))
|
||||
(map #(dissoc % :full-path)))))
|
||||
|
||||
;; create snippets from files
|
||||
;; save snippets in db
|
||||
Loading…
Add table
Add a link
Reference in a new issue