https://github.com/crisfeim/cli-bearpublish
π οΈ Static site generator for the Bear Notes app.
https://github.com/crisfeim/cli-bearpublish
bear-app bear-cli bear-frontend cli ssg static-site-generation static-site-generator swift
Last synced: 6 months ago
JSON representation
π οΈ Static site generator for the Bear Notes app.
- Host: GitHub
- URL: https://github.com/crisfeim/cli-bearpublish
- Owner: crisfeim
- License: mit
- Created: 2025-06-03T15:09:39.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-06-29T00:46:52.000Z (7 months ago)
- Last Synced: 2025-06-29T01:37:47.748Z (7 months ago)
- Topics: bear-app, bear-cli, bear-frontend, cli, ssg, static-site-generation, static-site-generator, swift
- Language: Swift
- Homepage: https://bearpublish.vercel.app
- Size: 2.56 MB
- Stars: 18
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: funding.yml
- License: LICENSE
Awesome Lists containing this project
README
# π»ββοΈ BearPublish


Static site generator for Bear Notes.
## Overview
**BearPublish** transforms a Bear Notes database into a static website.
## Project Architecture
### Modules
- `BearDatabase`: SQL logic to extract notes, metadata, tags, and files.
- `BearMarkdown`: Note content markdown parser with custom bear specific processors (file blocks, wikilinks, hex colors, etc...)
- `BearWebUI`: Web UI interface made with [Plot](https://github.com/JohnSundell/Plot).
- `BearDomain`: Intermediary domain objects that mediate between database and ui layers.
### Site Generation
- `BearSiteBuilder`: Builds `BearSite` with the needed data.
- `BearSiteRenderer`: Builds a `BearSiteRendered` with provided renderers from `BearSite`.
- `BearSiteGenerator`: Writes `BearSiteRendered` to disk (output url) and copies provided media files (files & images folders).
- `BearPublisher`: Composes the generator with the data passed data providers and needed renderers.
- `BearPublisherComposer`: Composes the publisher with defaults (data coming from the bear database and ui renders from the ui module)
- `BearPublisherCLI`: command-line interface using `ArgumentParser` that consumes `BearPublisherComposer`.
## Installation & Usage
Build and run the CLI. By default it outputs the site into a `dist` folder:
```
swift build -c release \
swift run
```
For custom output and paths, pass arguments:
```bash
swift build -c release
.build/release/BearPublishCLI \
--db-path /path/to/database.sqlite \
--files-folder-path /path/to/files \
--images-folder-path /path/to/images \
--output ./dist \
--title "My Static Site" \
--lang "en""
```
## What I'd Do Differently (and Hope to Add Eventually)
- **Drop HTMX for vanilla JS** β HTMX helped speed up the prototype, but it's overkill for what this project needs. Iβm mainly using `hx-get` and `hx-swap`, and the extra attributes feel like baggage.
- **Better routing** β Currently routes rely on query parameters (e.g., `?slug=note-slug`). Iβd prefer cleaner URLs like `bearsit.es/note-slug`.
## Ideas for Future Improvements
- **Bear default's theme selection** β Right now, the only supported theme is Duotone Light (β€οΈ). Iβd like to support theme selection via CLI:
`BearPublishCLI (...args...) --theme duotone-light`
- **Frontend theme switcher** β Ideally, visitors should be able to select themes from the generated site's UI.
- **Fix UI bug** β There's a minor issue when selecting nested menu items that arenβt expanded yet.
- **Mac App** β Iβd love to build a GUI for non-technical users to publish directly.
- **Tag-based note export** β Add support for filtering exported notes via tags:
`BearPublishCLI --tags [dev, code, articles]`
- **Companion app** β A lightweight CLI or GUI focused solely on exporting notes by tag in raw markdown.
- **Optimize CSS and JS** β These were initially written in 2023 to get a quick prototype running, so some parts may be ~~ugly~~~ repetitive or unoptimized.
- **Polish frontend and markdown parser** β Still have a lot of rough edges.
- **Add backlinks support** β As it was done in the original implementation.
- **Add live server** β As it was done in the original implementation.
- **Support external themes (frontend)** β Like a proper SSG, this would enable more granular control and flexibility in how content is displayed or customized.
## Contributing
This is a personal open source project. While Iβd love to keep improving it, for now I canβt guarantee active maintenance or support for feature requests. That said, improvements may happen as time and energy allow.
Feel free to open issues or pull requests β just know that response times may vary (and sometimes take a while).
## Third party
- [Plot](https://github.com/JohnSundell/Plot)
- [Markdownkit](https://github.com/objecthub/swift-markdownkit)
- [SQLite](https://github.com/stephencelis/SQLite.swift)
- [HTMX](https://github.com/bigskysoftware/htmx)
- [Hyperscript](https://github.com/bigskysoftware/_hyperscript)
- [PylonCSS](https://github.com/almonk/pylon)
## Related Projects
- [Bear PHP export script](https://gist.github.com/crisfeim/55e5c005f7e888ee0a380660b2dba8d5) β One of my first attempts of doing something like this.
- [Bearnotes Hugo theme](https://github.com/crisfeim/theme-hugo-bearnotes) β Basically the grandpa of this project.
- [Miyano](https://github.com/wuusn/miyano) β An awesome static site generator for Bear notes, built in Ruby by Wuusn. Main inspiration for this project.
## β Buy Me a Coffee
If you found this project useful and feel like supporting it, you can buy me a coffee β no pressure, but always appreciated!
[Buy me a coffee](https://buymeacoffee.com/crisfeim)
## License
MIT