Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #47 from tdzienniak/theme-selection
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 authored Oct 25, 2022
2 parents efebbeb + 94b10c8 commit 8b1b597
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Whenever you push changes to your Github repo, your graph will be published to t
- `src`: Publish graph src directory. Defaults to `` (empty string, root repo directory).
- `dest`: Publish destination directory. Defaults to `www`.
- `trace`: Whether or not to generate and publish trace file for debugging. This trace file will be uploaded as an artifact to the run. Defaults to `true`.
- `theme`: Selected theme. Defaults to `light`.

## How it works

Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ inputs:
description: >
Whether or not to generate trace file for debugging.
default: true
theme:
description: "selected theme"
required: true
default: "light"
branding:
icon: "arrow-up-circle"
color: "green"
Expand All @@ -36,7 +40,7 @@ runs:
options: |
-v ${{ github.workspace }}:/home/logseq/graph
run: |
xvfb-run node publish.mjs -p graph/${{ inputs.src }} -t ${{ inputs.trace }} -o graph/${{ inputs.dest }}
xvfb-run node publish.mjs -p graph/${{ inputs.src }} -t ${{ inputs.trace }} -o graph/${{ inputs.dest }} --theme ${{ inputs.theme }}
exit $?
- name: change exported files owner
shell: bash
Expand Down
18 changes: 18 additions & 0 deletions publish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ export async function loadLocalGraph(page, path) {
console.log("Graph loaded for " + path);
}

/**
*
* @param {import('playwright').Page} page
* @param {string} theme
*/
export async function selectTheme(page, theme) {
await page.click(".button >> .ls-icon-dots");
await page.click("a.menu-link >> text=Settings");
await page.click(`li >> i.mode-${theme}`);
await page.click("a.ui__modal-close");
}

/**
*
* @param {import('playwright').Page} page
Expand Down Expand Up @@ -133,6 +145,11 @@ async function main() {
alias: "o",
type: "string",
})
.option("theme", {
type: "string",
choices: ['light', 'dark'],
default: 'light'
})
.option("trace", {
alias: "t",
type: "boolean",
Expand Down Expand Up @@ -190,6 +207,7 @@ async function main() {
});

await loadLocalGraph(page, graphPath);
await selectTheme(page, argv.theme);
await publish(page, graphDistPath);

exportSuccess = true;
Expand Down

0 comments on commit 8b1b597

Please sign in to comment.