From b01048449354c53c79313d4dddcfa3e2b223f014 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Thu, 20 May 2021 20:44:59 -0400 Subject: [PATCH] Return `url` of new post on publish --- posts.go | 4 +++- read.go | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/posts.go b/posts.go index 107f0c1..ac2144c 100644 --- a/posts.go +++ b/posts.go @@ -125,6 +125,7 @@ type ( Views int64 `json:"views"` Owner *PublicUser `json:"-"` IsOwner bool `json:"-"` + URL string `json:"url,omitempty"` Collection *CollectionObj `json:"collection,omitempty"` } @@ -612,6 +613,7 @@ func newPost(app *App, w http.ResponseWriter, r *http.Request) error { newPost.extractData() newPost.OwnerName = username + newPost.URL = newPost.CanonicalURL(app.cfg.App.Host) // Write success now response := impart.WriteSuccess(w, newPost, http.StatusCreated) @@ -1124,7 +1126,7 @@ func (p *Post) processPost() PublicPost { func (p *PublicPost) CanonicalURL(hostName string) string { if p.Collection == nil || p.Collection.Alias == "" { - return hostName + "/" + p.ID + return hostName + "/" + p.ID + ".md" } return p.Collection.CanonicalURL() + p.Slug.String } diff --git a/read.go b/read.go index b11e657..7fb700e 100644 --- a/read.go +++ b/read.go @@ -315,7 +315,6 @@ func viewLocalTimelineFeed(app *App, w http.ResponseWriter, req *http.Request) e author = p.Collection.Title } else { author = "Anonymous" - permalink += ".md" } i := &Item{ Id: app.cfg.App.Host + "/read/a/" + p.ID,