An experimental IndieWeb site built in Go.

correctly determine and store microformat post type

Changed files
+14 -5
models
services
+4 -2
models/post.go
··· 3 3 import ( 4 4 "time" 5 5 6 + "go.hacdias.com/indielib/microformats" 6 7 "gorm.io/datatypes" 7 8 "gorm.io/gorm" 8 9 ) ··· 10 11 type Post struct { 11 12 ID ULID `gorm:"primaryKey;unique"` 12 13 13 - Type string 14 - Properties datatypes.JSON 14 + Type string 15 + MicroformatType microformats.Type 16 + Properties datatypes.JSON 15 17 16 18 CreatedAt time.Time 17 19 UpdatedAt time.Time
+10 -3
services/micropub.go
··· 21 21 "github.com/h2non/filetype" 22 22 "github.com/samber/lo" 23 23 24 + "go.hacdias.com/indielib/microformats" 24 25 "go.hacdias.com/indielib/micropub" 25 26 ) 26 27 ··· 102 103 return "", err 103 104 } 104 105 106 + mfType, _ := microformats.DiscoverType(map[string]any{ 107 + "type": req.Type, 108 + "properties": req.Properties, 109 + }) 110 + 105 111 post := &models.Post{ 106 - ID: models.NewULID(), 107 - Type: req.Type, 108 - Properties: props, 112 + ID: models.NewULID(), 113 + Type: req.Type, 114 + MicroformatType: mfType, 115 + Properties: props, 109 116 } 110 117 111 118 res := storage.GORM().Create(post)