This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-15
Channels
- # babashka (41)
- # beginners (47)
- # calva (7)
- # cider (5)
- # cljsrn (2)
- # clojure (38)
- # clojure-europe (74)
- # clojure-nl (2)
- # clojure-spec (1)
- # clojure-uk (38)
- # clojurescript (42)
- # component (30)
- # core-async (2)
- # cryogen (6)
- # cursive (47)
- # datahike (7)
- # datomic (18)
- # defnpodcast (1)
- # fulcro (17)
- # graalvm (8)
- # graphql (4)
- # helix (5)
- # honeysql (5)
- # introduce-yourself (1)
- # jobs (5)
- # jobs-discuss (4)
- # malli (20)
- # meander (4)
- # mental-health (1)
- # off-topic (41)
- # pathom (18)
- # podcasts-discuss (2)
- # re-frame (20)
- # react (1)
- # reagent (22)
- # reitit (2)
- # releases (2)
- # remote-jobs (1)
- # reveal (2)
- # sci (10)
- # shadow-cljs (42)
- # sql (20)
- # tools-deps (7)
- # vim (2)
- # xtdb (51)
hmm well normally that shouldn't be a problem but I guess there is an issue with electron and eval
then
as I did a require in another ns which is used in the application and is compiled, then suddenly everything started to work everywhere and in every ns
do you have any custom :js-options
or so in your build config? anything electron related?
Is it possible to call a node script from cljs? If so, how do I configure my shadow-cljs.edn
so that I can call it?
Nevermind, I finally figured out the classpath business.
(ns app.data
(:require [clojure.edn :as edn]
[shadow.resource]
["/org_processor" :as org]
))
But now I get a weird error.
[:app] Compiling ...
[:app] Build failure:
Closure compilation failed with 1 errors
--- org_processor.js:3
Parse error. '}' expected
ah you mean using a JS file in your build. by "call a node script" I assuming you mean run node some-script.js
or so 😛
yeah, I want to use a node script as it interacts with my local filesystem, and shadow.resource
just doesn’t suit my needs.
Here’s my script.
(ns scripts.org-processor
(:require ["unified" :as unified]
["rehype-stringify" :as html]
["uniorg-parse" :as uniorg]
["uniorg-rehype" :as rehype]
["uniorg-extract-keywords" :refer (extractKeywords)]
[cljs-node-io.core :as io :refer [slurp spit file-seq]]
))
(def processor
(->
(unified)
(.use uniorg)
(.use extractKeywords)
(.use rehype)
(.use html)))
#_(def org-string "
#+title: Lorem Ipsum
#+subtitle: stuff test
#+date: 2021-04-15
#+tags: test
#+author: Christian Westrom
#+id: test-1
* Here's some stuff
* Here's more stuff
- more stuff")
(defn process-org
[org]
(.processSync processor org))
(defn org->html
[org-string]
(.-contents (process-org org-string)))
(defn org->data
[org-string]
(js->clj (.-data (process-org org-string))
:keywordize-keys true))
(defn blog-post
[org-string]
{:content (org->html org-string)
:data (org->data org-string)})
(defn ^:export all-posts
[path]
(js/console.log (map #(blog-post (slurp %)) (rest (file-seq path)))))
Now the function all-posts
just outputs to the console for now, but I want to call it from my reagent site.
I do NOT recommend trying to run that script as part of the compilation. that'll just end up with unnecessary avoidable problems all over the place
Looks like I need ajax then lol
Because there’s no equivalent to file-seq
in shadow-resource
.
so you could have that generate a single EDN or JSON file and just shadow.resource that