diff --git a/bskyweb/cmd/embedr/snippet.go b/bskyweb/cmd/embedr/snippet.go index e65f38a6..b93acb2c 100644 --- a/bskyweb/cmd/embedr/snippet.go +++ b/bskyweb/cmd/embedr/snippet.go @@ -23,7 +23,7 @@ func (srv *Server) postEmbedHTML(postView *appbsky.FeedDefs_PostView) (string, e return "", err } - const tpl = `
` + const tpl = `{{ .PostText }}
— {{ .PostAuthor }} {{ .PostIndexedAt }}
` t, err := template.New("snippet").Parse(tpl) if err != nil { @@ -31,6 +31,12 @@ func (srv *Server) postEmbedHTML(postView *appbsky.FeedDefs_PostView) (string, e return "", err } + sortAt := postView.IndexedAt + createdAt, err := syntax.ParseDatetime(post.CreatedAt) + if nil == err && createdAt.String() < sortAt { + sortAt = createdAt.String() + } + var lang string if len(post.Langs) > 0 { lang = post.Langs[0] @@ -41,8 +47,6 @@ func (srv *Server) postEmbedHTML(postView *appbsky.FeedDefs_PostView) (string, e } else { authorName = fmt.Sprintf("@%s", postView.Author.Handle) } - fmt.Println(postView.Uri) - fmt.Println(fmt.Sprintf("%s", postView.Uri)) data := struct { PostURI template.URL PostCID string @@ -50,6 +54,8 @@ func (srv *Server) postEmbedHTML(postView *appbsky.FeedDefs_PostView) (string, e PostText string PostAuthor string PostIndexedAt string + ProfileURL template.URL + PostURL template.URL WidgetURL template.URL }{ PostURI: template.URL(postView.Uri), @@ -57,7 +63,9 @@ func (srv *Server) postEmbedHTML(postView *appbsky.FeedDefs_PostView) (string, e PostLang: lang, PostText: post.Text, PostAuthor: authorName, - PostIndexedAt: postView.IndexedAt, // TODO: createdAt? + PostIndexedAt: sortAt, + ProfileURL: template.URL(fmt.Sprintf("https://bsky.app/profile/%s?ref_src=embed", aturi.Authority())), + PostURL: template.URL(fmt.Sprintf("https://bsky.app/profile/%s/post/%s?ref_src=embed", aturi.Authority(), aturi.RecordKey())), WidgetURL: template.URL("https://embed.bsky.app/static/embed.js"), }{{ .PostText }}
— {{ .PostAuthor }} {{ .PostIndexedAt }}