···1313go get -u tangled.org/anhgelus.world/goat-site
1414```
15151616-Each Standard.site lexicon is implemented:
1616+Each [Standard.site lexicon](https://standard.site/#definitions) is implemented:
1717- `Publication` is for `site.standard.publication`;
1818- `Document` is for `site.standard.document`;
1919- `Subscription` is for `site.standard.graph.subscription`.
···5151}
5252```
53535454-But, if you use `site.GetDocument` to retrieve one, it will return a simple `site.Document` without your custom content!
5454+But if you use `site.GetDocument` to retrieve one, it will return a simple `site.Document` without your custom content!
5555The `Document.Content` field is a `site.RecordJSON`, a wrapper.
5656You can get the type of the content with `RecordJSON.Type` and the raw bytes with `RecordJSON.Raw`.
5757You can also directly parse your `Content` with `RecordJSON.As`:
···9292 mp["foo"] = "bar"
9393 return mp, nil
9494}
9595-// the future call to site.MarshalToMap on *Content will return map[string]any{"foo":"bar"}.
9595+// the future call to site.MarshalToMap on *Content
9696+// will return map[string]any{"foo":"bar"}.
9697```
+12-2
lexicons.go
···5555)
56565757// RecordJSON is used to encode and to decode [Record] from JSON.
5858+//
5959+// If the [Record] is known by the library, it is decoded in [RecordJSON.Record].
6060+// Else its type is filled in [RecordJSON.Type] and its raw bytes are placed in [RecordJSON.Raw].
6161+//
6262+// See [AsJSON] to create a [RecordJSON] from a [Record].
5863type RecordJSON struct {
5964 // Record parsed.
6065 // Nil if [Record] is unknown.
···6570 // Raw returns bytes stored if [Record] is unknown.
6671 // Set after [json.Unmarshal].
6772 Raw []byte
7373+}
7474+7575+// AsJSON wraps a [Record] as a [RecordJSON].
7676+func AsJSON(r Record) *RecordJSON {
7777+ return &RecordJSON{Record: r}
6878}
69797080// As unmarshals the [RecordJSON] as the provided [Record].
···240250//
241251// Rkey can be nil.
242252func createRecord[T Record](ctx context.Context, client lexutil.LexClient, collection string, repo syntax.AtIdentifier, rkey *syntax.RecordKey, v T) (*Result, error) {
243243- mp, err := MarshalToMap(&RecordJSON{Record: v})
253253+ mp, err := MarshalToMap(AsJSON(v))
244254 if err != nil {
245255 return nil, err
246256 }
···266276// updateRecord T in a repo with the given rkey.
267277// Always tries to validate the [Document] against the lexicon saved.
268278func updateRecord[T Record](ctx context.Context, client lexutil.LexClient, collection string, repo syntax.AtIdentifier, rkey syntax.RecordKey, v T) (*Result, error) {
269269- mp, err := MarshalToMap(&RecordJSON{Record: v})
279279+ mp, err := MarshalToMap(AsJSON(v))
270280 if err != nil {
271281 return nil, err
272282 }
+2-2
map.go
···4545 return nil, nil
4646 }
4747 val := v.Interface()
4848- if conv, ok := val.(Record); ok {
4949- val = &RecordJSON{Record: conv}
4848+ if r, ok := val.(Record); ok {
4949+ val = AsJSON(r)
5050 }
5151 if conv, ok := val.(MarshalerMap); ok {
5252 return conv.MarshalMap()