Search Apps Documentation Source Content File Folder Download Copy Actions Download

doc.gno

1.18 Kb ยท 51 lines
 1/*
 2Package blog is a simple blogging system that allows users to create, update, delete, and render blog posts.
 3
 4It supports features like pagination, filtering by tags and authors, and rendering posts in Markdown format. The package is designed to be extensible and can be integrated into larger applications.
 5
 6Example:
 7
 8	import "gno.land/p/lou/blog"
 9
10	func init() {
11		myBlog, _ = blog.NewBlog(
12			"Personal Blog",
13			"g1pfyhn0d7g4tnp6wft9ge4cuu88ppr9u8mdggfs",
14			blog.WithUserResolver(myResolver),
15		)
16	}
17
18	func CreatePost(_ realm, slug, title, body, publicationDate, authors, tags string) {
19		authorsField := strings.Split(authors, " ")
20		tagsField := strings.Split(tags, " ")
21
22		post, err := blog.NewPost(
23			slug,
24			title,
25			body,
26			publicationDate,
27			std.OriginCaller().String(),
28			authorsField,
29			tagsField,
30		)
31		if err != nil {
32			panic(err)
33		}
34		if err := myBlog.AddPost(post); err != nil {
35			panic(err)
36		}
37	}
38
39	func Render(path string) string {
40		return myBlog.Render(path)
41	}
42
43	func myResolver(input string) (string, bool) {
44		data, ok := users.ResolveAny(input)
45		if !ok || data == nil {
46			return "", false
47		}
48		return data.Name(), true
49	}
50*/
51package blog // import "gno.land/p/lou/blog"