♻️ Constructors are handy

This commit is contained in:
Dan Jones 2023-06-30 14:56:52 -05:00
commit fb84ebb9db

View file

@ -54,23 +54,24 @@ type Config struct {
Id string `toml:"id"`
}
func (c Config) GetIcon() vocab.IRI {
// @todo return a media object, instead of an IRI
func (c Config) GetIcon() *vocab.Object {
var link = vocab.ObjectNew(vocab.ImageType)
link.URL = vocab.IRI(c.IconUrl)
// @todo figure out actual mime type
link.MediaType = vocab.MimeType("image/jpeg")
return vocab.IRI(c.IconUrl)
return link
}
func (c Config) GetActor() vocab.Actor {
return vocab.Actor{
// Id:
Name: vocab.NaturalLanguageValues{
vocab.LangRefValue{
Ref: "en",
Value: []byte(c.Name),
},
},
Icon: c.GetIcon(),
}
func (c Config) GetActor() *vocab.Actor {
var me = vocab.PersonNew(vocab.IRI(c.Id))
me.Name = vocab.DefaultNaturalLanguageValue(c.Name)
me.Icon = c.GetIcon()
// @todo parse markdown into html
me.Summary = vocab.DefaultNaturalLanguageValue(c.Summary)
return me
}
var config Config