Huno (HUgo NOstr) gives you access to your Nostr events when generating a static site with Hugo.
Running huno fetches the events specified in hugo.toml and lays them out with additional helpful data in the data/nostr
directory of your Hugo project. This makes them accessible in content adapters
and templates. Subsequent runs of huno syncs new events and updates or deletes events as needed.
git clone https://github.com/straumer/huno.git
cargo install --path huno
In the root of your Hugo project, write to hugo.toml:
[nostr]
author = "npub1wukm87rrl4jh680jr0h0ceuk27z2dpa0y9swl4dvpa8g2696dz6qauayfa"
Replace npub... with your own npub. Then run huno. This generates JSON files in data/nostr organized like this:
state.json
events
<id1>
event.json
meta.json
<id2>
<id3>
...
Now the events can be accessed in content adapters and
templates via the data object as
hugo.Data.nostr.
Use the hugo-nostr module to easily include that event data as content
in your content directory via prepackaged partials.
If no relays are specified, huno discovers where to get the events based on a set of default relays. In order to only get events from specific relays, they can be specified as such:
[nostr]
author = "npub1wukm87rrl4jh680jr0h0ceuk27z2dpa0y9swl4dvpa8g2696dz6qauayfa"
relays = ["wss://myrelay.xyz", ...]
Discovery relays can also be specified to use them instead of the defaults:
[nostr]
author = "npub1wukm87rrl4jh680jr0h0ceuk27z2dpa0y9swl4dvpa8g2696dz6qauayfa"
discovery_relays = ["wss://mydiscoveryrelay.xyz", ...]
Instead of only specifying a single author, a filter can be used instead (see NIP-01 for details):
[nostr]
[nostr.filter]
authors = [
"npub1wukm87rrl4jh680jr0h0ceuk27z2dpa0y9swl4dvpa8g2696dz6qauayfa",
"npub1wukm87rrl4jh680jr0h0ceuk27z2dpa0y9swl4dvpa8g2696dz6qauayfb"
]
kinds = [0, 1, 5]
When author is used, the default is kinds = [0, 1, 5, 30023].
The above configuration has been tested to work, but other ones may or may not work for now.
- nip05 support in author field in hugo.conf
- introduce concurrency in file writing and possibly more