Skip to content

Commit

Permalink
Add accent-color option for action and CLI
Browse files Browse the repository at this point in the history
Also bumped to latest frontend
  • Loading branch information
logseq-cldwalker committed Nov 30, 2023
1 parent 587251d commit 101bb7d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
with:
graph-directory: test/publish-test-graph
theme-mode: dark
accent-color: cyan

- name: add a nojekyll file # to make sure asset paths are correctly identified
- name: Add a nojekyll file # to make sure asset paths are correctly identified
run: touch $GITHUB_WORKSPACE/www/.nojekyll
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: logseq/publish-spa@v0.2.0
- name: add a nojekyll file # to make sure asset paths are correctly identified
- name: Add a nojekyll file # to make sure asset paths are correctly identified
run: touch $GITHUB_WORKSPACE/www/.nojekyll
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
Expand Down Expand Up @@ -77,6 +77,10 @@ action with 0.9.2.

Optional: Theme mode for frontend. Can be "dark" or "light". Defaults to "light".

##### `accent-color`

Optional: Accent color for frontend. Can be one of "tomato", "red", "crimson", "pink", "plum", "purple", "violet", "indigo", "blue", "cyan", "teal", "green", "grass", "orange", "brown". Defaults to "blue".

### CLI

To use this as a CLI locally, first install
Expand Down
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ inputs:
version:
description: "Frontend version of Logseq - git tag or SHA"
required: true
default: '0.9.8'
default: '0.10.0'
theme-mode:
description: "Theme mode of frontend. Can be 'dark' or 'light'"
required: false
default: 'light'
accent-color:
description: "Accent color of frontend. 10+ colors available."
required: false
default: 'blue'

runs:
using: "composite"
Expand Down Expand Up @@ -84,5 +88,5 @@ runs:
shell: bash

- name: Export graph to directory
run: cd .logseq-publish-spa && node publish_spa.mjs ${{ inputs.output-directory }} --static-directory .logseq-logseq/static --directory ${{ inputs.graph-directory }} --theme-mode ${{ inputs.theme-mode }}
run: cd .logseq-publish-spa && node publish_spa.mjs ${{ inputs.output-directory }} --static-directory .logseq-logseq/static --directory ${{ inputs.graph-directory }} --theme-mode ${{ inputs.theme-mode }} --accent-color ${{ inputs.accent-color }}
shell: bash
13 changes: 7 additions & 6 deletions nbb.edn
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{:deps
{logseq/graph-parser
{:git/url "https://github.com/logseq/logseq"
:git/sha "82cf4d3c65acbf230a3170640fe271dd74095067"
:git/tag "0.9.8"
:git/sha "5a4bba13787c39616115e447fac7b413986580b7"
:git/tag "0.10.0"
:deps/root "deps/graph-parser"}
#_{:local/root "../logseq/deps/graph-parser"}
logseq/publishing
{:git/url "https://github.com/logseq/logseq"
:git/sha "82cf4d3c65acbf230a3170640fe271dd74095067"
:git/tag "0.9.8"
:git/sha "5a4bba13787c39616115e447fac7b413986580b7"
:git/tag "0.10.0"
:deps/root "deps/publishing"}
#_{:local/root "../logseq/deps/publishing"}
;; TODO: Remove workaround for error: 'Unable to compare versions for logseq/db'
logseq/db
{:git/url "https://github.com/logseq/logseq"
:git/sha "82cf4d3c65acbf230a3170640fe271dd74095067"
:git/tag "0.9.8"
:git/sha "5a4bba13787c39616115e447fac7b413986580b7"
:git/tag "0.10.0"
:deps/root "deps/db"}}}
30 changes: 23 additions & 7 deletions src/logseq/publish_spa.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@
(println "Warning: Skipping :theme-mode since it is invalid. Must be 'light' or 'dark'.")
"light"))))

(def valid-colors
"From frontend.colors/color-list"
[:tomato :red :crimson :pink :plum :purple :violet :indigo :blue :cyan :teal :green :grass :orange :brown])

(defn- get-accent-color [color*]
(let [color (keyword (or color* "blue"))]
(if (contains? (set valid-colors) color)
color
(do
(println "Warning: Skipping :accent-color since it is invalid.")
:blue))))

(defn- build-common-export-options
[options]
{:ui/theme (get-theme-mode (:theme-mode options))
:ui/radix-color (get-accent-color (:accent-color options))
:notification-fn (fn [msg]
(if (= "error" (:type msg))
(do (js/console.error (:payload msg))
(js/process.exit 1))
(js/console.log (:payload msg))))})

(defn ^:api -main
[& args]
(let [options (cli/parse-opts args {:spec spec})
Expand All @@ -57,12 +79,6 @@
static-dir
graph-dir
output-path
{:repo-config repo-config
:ui/theme (get-theme-mode (:theme-mode options))
:notification-fn (fn [msg]
(if (= "error" (:type msg))
(do (js/console.error (:payload msg))
(js/process.exit 1))
(js/console.log (:payload msg))))})))
(merge (build-common-export-options options) {:repo-config repo-config}))))

#js {:main -main}

0 comments on commit 101bb7d

Please sign in to comment.