Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

blog package

Overview

Package blog is moul's personal blog on gno.land: one realm, one author, posts that live in chain storage rather than in the code.

The shape

A post is markdown plus four fields (slug, title, date, tags). Writing one is a single Set transaction, so publishing never redeploys the realm and fixing a typo costs one small call instead of a new package path.

The reader-facing paths are deliberately short, because they get pasted into other people's chats:

Example
1gno.land/r/moul/blog             the index, newest first
2gno.land/r/moul/blog:<slug>      one post
3gno.land/r/moul/blog:t/<tag>     every post carrying a tag

Ordering without sort

gno has no sort.Slice, and avl.Tree iterates by key. So posts live in two trees: `posts` keyed by slug, for the O(log n) lookup a permalink needs, and `order` keyed by "<date>/<slug>", walked in reverse for newest-first. The date is YYYY-MM-DD precisely so that lexical order is chronological order, which is what makes the second tree free.

Versioning

gnomod.toml declares private = true, which lets the creator re-add the package at this exact path. That redeploy re-runs init() and WIPES every post here, so the markdown kept off chain is the source of truth and tools/gnoblog pushes it back. Trading that risk for a stable URL is the whole design: a /v1 would break every link already shared, a redeploy does not, and Manifest() makes restoring the content one diff.

Function

Count

func Count() int

Count returns the number of published posts.

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/blog.Count()"

Result