Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7153c10
Update CLI to work with db graphs
logseq-cldwalker Aug 15, 2023
a7c39a2
Fix some db graphs failing on validation check
logseq-cldwalker Aug 16, 2023
3186605
Add test db graph
logseq-cldwalker Aug 16, 2023
d8a2360
Forgot to bump frontend :duh:
logseq-cldwalker Aug 17, 2023
0094015
Update to feat/db with outline dep done
logseq-cldwalker Sep 8, 2023
7d4a77c
Update test graph
logseq-cldwalker Sep 8, 2023
e8e7ab2
fix deploy not working for external repos
logseq-cldwalker Sep 15, 2023
dd1bdf9
Update to latest feat/db
logseq-cldwalker Sep 15, 2023
57923bb
Update to latest feat/db to include fixes for public property
logseq-cldwalker Sep 28, 2023
320783b
Add accent-color option for action and CLI
logseq-cldwalker Nov 15, 2023
e4e67fc
Update nbb and sqlite changes for datascript.storage update
logseq-cldwalker Dec 15, 2023
3c53cbf
Bump to latest nbb-logseq and feat/db
logseq-cldwalker Jan 18, 2024
d4f1f2e
add nbb.edn workaround for common deps bug
logseq-cldwalker Jan 18, 2024
5181953
Bump frontend to include shadow-cljs.edn fix
logseq-cldwalker Jan 18, 2024
94cb9c6
Update deps and try test deploy again
logseq-cldwalker Jan 19, 2024
bf65d05
fix lint
logseq-cldwalker Jan 19, 2024
87de8f6
Bump to new frontend with worker path fix
logseq-cldwalker Jan 19, 2024
11e320c
bump frontend to version that fixes 2 major opfs bugs
logseq-cldwalker Jan 19, 2024
33fd029
Update test graph
logseq-cldwalker Jan 19, 2024
6097a38
Point nbb.edn to a commit that is on feat/db
logseq-cldwalker Jan 19, 2024
eb5e961
Bump nbb and frontend to versions with bug fix + new page configure
logseq-cldwalker Jan 22, 2024
48f86b0
Bump to first version with lazy loaded frontend
logseq-cldwalker Feb 15, 2024
517e477
fix: update publish to work with latest db graphs
logseq-cldwalker Oct 31, 2024
0b1f31a
chore: bump deps
logseq-cldwalker Oct 31, 2024
1b0e354
Update published test db
logseq-cldwalker Oct 31, 2024
d1c37c5
fix: bump nbb to fix publishing
logseq-cldwalker Oct 31, 2024
7a3e8b8
forgot to bump logseq for testing publishing
logseq-cldwalker Oct 31, 2024
ff40980
Update test graph to be public :lol:
logseq-cldwalker Oct 31, 2024
c5569fe
Bump to latest logseq + rebuild test graph
logseq-cldwalker Jul 12, 2025
429ea33
fix: update node for latest logseq
logseq-cldwalker Jul 12, 2025
d607ea0
chore: update deps
logseq-cldwalker Jul 12, 2025
111c7ed
fix: update outdated node deps
logseq-cldwalker Jul 12, 2025
f0023c3
fix: rename ns for latest logseq
logseq-cldwalker Jul 12, 2025
4f732d9
Update frontend and backend to use latest logseq
logseq-cldwalker Jul 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: CI

on:
Expand All @@ -10,10 +10,10 @@

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand All @@ -22,7 +22,7 @@
uses: DeLaGuardo/setup-clojure@master
with:
cli: 1.11.1.1237
bb: 1.0.168
bb: 1.12.205

- name: Run clj-kondo lint
run: clojure -M:clj-kondo --lint src
Expand All @@ -39,5 +39,5 @@
- name: Check outdated dependencies
uses: liquidz/antq-action@main
with:
excludes: 'borkdude/carve clojure/brew-install'
excludes: 'borkdude/carve clojure/brew-install logseq/publish-spa'

12 changes: 7 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches: [main]
# branches: [main]
paths-ignore:
- '*.md'
permissions:
Expand All @@ -11,15 +11,17 @@ jobs:
name: Run the action on a test graph and publish
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build graph's SPA
uses: logseq/publish-spa@main
uses: logseq/publish-spa@feat/db
with:
graph-directory: test/publish-test-graph
graph-directory: test/publish-test-db-graph
theme-mode: dark
accent-color: cyan
version: 3c93fd2637d9615a3fd99b11c73d40a8c4f0ff2d

- 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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Run the action on a test graph
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run github action
uses: logseq/publish-spa@main
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
16 changes: 11 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,35 @@ inputs:
version:
description: "Frontend version of Logseq - git tag or SHA"
required: true
default: '0.9.8'
default: '65640ed8857199d89268295863cd556f5d90ea0b'
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"
steps:
# First, build logseq's static/ and publishing assets
- name: Checkout logseq
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: logseq/logseq
path: .logseq-logseq
ref: ${{ inputs.version }}

## Placed here since node step requires it
- name: Checkout action
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: logseq/publish-spa
path: .logseq-publish-spa
# TODO: Remove when merging
ref: feat/db

- name: Set up Clojure
uses: DeLaGuardo/setup-clojure@master
Expand All @@ -45,7 +51,7 @@ runs:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '22'
cache: 'yarn'
cache-dependency-path: .logseq-publish-spa/yarn.lock

Expand Down Expand Up @@ -84,5 +90,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
2 changes: 1 addition & 1 deletion bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:deps
{io.github.logseq/bb-tasks
#_{:local/root "../bb-tasks"}
{:git/sha "70d3edeb287f5cec7192e642549a401f7d6d4263"}}
{:git/sha "acb3d3d5d38c4ac16f617cb10ae6f99fe1b8de6e"}}

:pods
{clj-kondo/clj-kondo {:version "2023.03.17"}}
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{:aliases
{:clj-kondo
{:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.05.26"}}
{:replace-deps {clj-kondo/clj-kondo {:mvn/version "2025.06.05"}}
:main-opts ["-m" "clj-kondo.main"]}
:outdated
{:replace-deps {com.github.liquidz/antq {:mvn/version "RELEASE"}}
Expand Down
19 changes: 12 additions & 7 deletions nbb.edn
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
{:deps
{logseq/graph-parser
{:git/url "https://github.com/logseq/logseq"
:git/sha "82cf4d3c65acbf230a3170640fe271dd74095067"
:git/tag "0.9.8"
:git/sha "65640ed8857199d89268295863cd556f5d90ea0b"
: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 "65640ed8857199d89268295863cd556f5d90ea0b"
: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"
:deps/root "deps/db"}}}
:git/sha "65640ed8857199d89268295863cd556f5d90ea0b"
:deps/root "deps/db"}
#_{:local/root "../logseq/deps/db"}
;; TODO: Remove workaround for error: 'Unable to compare versions for logseq/common'
logseq/common
{:git/url "https://github.com/logseq/logseq"
:git/sha "65640ed8857199d89268295863cd556f5d90ea0b"
:deps/root "deps/common"}
#_{:local/root "../logseq/deps/db"}}}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
},
"homepage": "https://github.com/logseq/publish-spa#readme",
"dependencies": {
"@logseq/nbb-logseq": "^1.2.173",
"@logseq/nbb-logseq": "logseq/nbb-logseq#feat-db-v24",
"better-sqlite3": "11.10.0",
"fs-extra": "^9.1.0",
"mldoc": "^1.5.1"
"mldoc": "^1.5.9"
}
}
87 changes: 69 additions & 18 deletions src/logseq/publish_spa.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
[logseq.publishing :as publishing]
["fs" :as fs]
["path" :as node-path]
[logseq.db.common.sqlite-cli :as sqlite-cli]
[datascript.core :as d]
[babashka.cli :as cli]
[clojure.edn :as edn]))
[clojure.edn :as edn]
[logseq.db.sqlite.util :as sqlite-util]))

(defn- get-db [graph-dir]
(let [{:keys [conn]} (gp-cli/parse-graph graph-dir {:verbose false})] @conn))
Expand All @@ -15,14 +18,17 @@
{:directory {:desc "Graph directory to export"
:alias :d
:default "."}
:dev {:coerce :boolean
:desc "Dev mode"}
:help {:alias :h
:desc "Print help"}
:static-directory {:desc "Logseq's static directory"
:alias :s
:default "../logseq/static"}})

(defn- validate-directories [graph-dir static-dir]
(when-not (fs/existsSync (node-path/join graph-dir "logseq" "config.edn"))
(defn- validate-directories [graph-dir static-dir {:keys [graph-db?]}]
(when (and (not graph-db?)
(not (fs/existsSync (node-path/join graph-dir "logseq" "config.edn"))))
(println (str "Error: Invalid graph directory '" graph-dir
"' as it has no logseq/config.edn."))
(js/process.exit 1))
Expand All @@ -39,6 +45,56 @@
(println "Warning: Skipping :theme-mode since it is invalid. Must be 'light' or 'dark'.")
"light"))))

(def ^:private 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))
:dev? (boolean (:dev 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- publish-file-graph [static-dir graph-dir output-path options]
(let [repo-config (-> (node-path/join graph-dir "logseq" "config.edn") fs/readFileSync str edn/read-string)]
(publishing/export (get-db graph-dir)
static-dir
graph-dir
output-path
(merge (build-common-export-options options)
{:repo (node-path/basename graph-dir)
:repo-config repo-config}))))

(defn- publish-db-graph [static-dir graph-dir output-path options]
(let [db-name (node-path/basename graph-dir)
conn (sqlite-cli/open-db! (node-path/dirname graph-dir) db-name)
repo-config (-> (d/q '[:find ?content
:where [?b :file/path "logseq/config.edn"] [?b :file/content ?content]]
@conn)
ffirst
edn/read-string)]
(publishing/export @conn
static-dir
graph-dir
output-path
(merge (build-common-export-options options)
{:repo (str sqlite-util/db-version-prefix db-name)
:repo-config repo-config
:db-graph? true}))))

(defn ^:api -main
[& args]
(let [options (cli/parse-opts args {:spec spec})
Expand All @@ -48,21 +104,16 @@
(js/process.exit 1))
_ (when js/process.env.CI (println "Options:" (pr-str options)))
[static-dir graph-dir output-path]
;; Offset relative paths for CI since it is run in a different dir
(map #(if js/process.env.CI (node-path/resolve ".." %) %)
(map #(if js/process.env.CI
;; Offset relative paths for CI since it is run in a different dir
(node-path/resolve ".." %)
;; Resolve static dir so that copied js assets don't have incorrect relative paths
(node-path/resolve "." %))
[(:static-directory options) (:directory options) (first args)])
_ (validate-directories graph-dir static-dir)
repo-config (-> (node-path/join graph-dir "logseq" "config.edn") fs/readFileSync str edn/read-string)]
(publishing/export (get-db graph-dir)
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))))})))
graph-db? (sqlite-cli/db-graph-directory? graph-dir)
_ (validate-directories graph-dir static-dir {:graph-db? graph-db?})]
(if graph-db?
(publish-db-graph static-dir graph-dir output-path options)
(publish-file-graph static-dir graph-dir output-path options))))

#js {:main -main}
Binary file added test/publish-test-db-graph/db.sqlite
Binary file not shown.
Loading