example

command
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

README

blogadmin example

A self-contained example server that boots blogadmin on an in-memory SQLite database. No external services required.

Run

go run ./example

Then open http://localhost:8080/ in your browser.

What it does

  • Creates an in-memory SQLite database (reset on every restart)
  • Initializes blogstore, customstore, and settingstore with auto-migration
  • Seeds 60 sample posts, 10 categories, and 20 tags
  • Mounts the blog admin panel at /admin/blog
  • Serves a landing page at / that links into the admin

AI features

AI controllers (title generator, post generator, post editor) require an LLM factory. This example leaves LlmFactory as nil, so AI controllers return an error to the user instead of making API calls. To enable AI features, provide a real LlmFactoryFunc:

admin, err := blogadmin.New(blogadmin.AdminOptions{
    Store:        store,
    Logger:       logger,
    CustomStore:  customStore,
    SettingStore: settingStore,
    LlmFactory: func() (llm.LlmInterface, error) {
        return llm.NewLlm(llm.LlmOptions{
            Provider: llm.PROVIDER_OPENAI,
            ApiKey:   os.Getenv("OPENAI_API_KEY"),
            Model:    "gpt-4o",
        })
    },
    // ...
})

Persistence

To use a file-based database instead of in-memory, change dbFile:

const dbFile = "blogadmin_example.db"

Data will persist across restarts.

Documentation

Overview

Example blogadmin server.

Boots an HTTP server with an in-memory SQLite database and mounts the blogadmin panel at /admin/blog. No external services required.

Run from the blogadmin module root:

go run ./example

Then open http://localhost:8080/ in your browser.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL