diff --git a/action.yml b/action.yml index 43b1656..d244544 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,9 @@ name: Logseq Excalidraw to SVG description: Converts excalidraw to svg references +inputs: + home-md-file: + description: Markdown file of the page you see when accessing the published site + required: false runs: using: composite steps: @@ -10,6 +14,6 @@ runs: python-version: '3.12' # Optional - x64 or x86 architecture, defaults to x64 architecture: 'x64' - - run: python ${{ github.action_path }}/main.py ${{ github.workspace }} + - run: python ${{ github.action_path }}/main.py ${{ github.workspace }} ${{ inputs.home-md-file}} shell: bash diff --git a/main.py b/main.py index 4567244..0091342 100644 --- a/main.py +++ b/main.py @@ -47,12 +47,20 @@ def main() -> None: :return: """ vault_path = Path(argv[1]).expanduser() + home_md_file = None + if len(argv) > 2: + home_md_file = Path(argv[2]).expanduser() + if not home_md_file: + home_md_file = None pages, draws = get_draws(vault_path) + missing_any_svgs = False + replace_dict = {} for draw, svg in iter_svgs(vault_path, draws): if svg is None: replace_dict[f"[[{draw}]]"] = "

MISSING IMAGE

" + missing_any_svgs = True else: replace_dict[f"[[{draw}]]"] = f"![{draw}](../{svg})" @@ -66,6 +74,25 @@ def main() -> None: with open(page, "w") as f: f.write(content) + if missing_any_svgs and home_md_file is not None: + with open(home_md_file, "a") as f: + f.write("\n" + """ +-

Some drawings were not loaded

+\t- ## How to fix as a Contributor +\t\t- drawings are located in /draws +\t\t- each ".excalidraw" drawing file should have an equivalent ".svg" file in /assets/excalidraw_svg with the same basename +\t\t- ### Example +\t\t ``` +\t\t /draws/2023-10-08-21-23-31.excalidraw +\t\t /assets/excalidraw_svg/2023-10-08-21-23-31.svg +\t\t ``` +\t\t- to create a missing svg file, head to https://excalidraw.com/, paste the .excalidraw file, Click the Hamburger Menu > Export Image +\t\t\t- Enable "Background" and check if you need Dark or Light theme +\t\t\t- Click "SVG" and copy to /assets/excalidraw_svgs +\t\t\t- Rename the file so the base names match +""" + ) + if __name__ == "__main__": main()