Use video thumbnail as og:image for posts with video embeds (#9877)
This commit is contained in:
+21
-14
@@ -6,21 +6,26 @@ To build the SPA bundle (`bundle.web.js`), first get a JavaScript development
|
|||||||
environment set up. Either follow the top-level README, or something quick
|
environment set up. Either follow the top-level README, or something quick
|
||||||
like:
|
like:
|
||||||
|
|
||||||
# install nodejs
|
```bash
|
||||||
nvm install
|
# install nodejs
|
||||||
nvm use
|
nvm install
|
||||||
npm install --global yarn
|
nvm use
|
||||||
|
npm install --global yarn
|
||||||
|
|
||||||
# setup tools and deps (in top level of this repo)
|
# setup tools and deps (in top level of this repo)
|
||||||
yarn install --frozen-lockfile
|
yarn install --frozen-lockfile
|
||||||
|
|
||||||
# run yarn web dev server, if you wanted
|
# run yarn web dev server, if you wanted
|
||||||
yarn web
|
yarn web
|
||||||
|
```
|
||||||
|
|
||||||
Then build and copy over the big 'ol `bundle.web.js` file:
|
Then build and copy over the big 'ol `bundle.web.js` file:
|
||||||
|
|
||||||
# in the top level of this repo
|
|
||||||
yarn build-web
|
```bash
|
||||||
|
# in the top level of this repo
|
||||||
|
yarn build-web
|
||||||
|
```
|
||||||
|
|
||||||
### Golang Daemon
|
### Golang Daemon
|
||||||
|
|
||||||
@@ -28,11 +33,13 @@ Install golang. We generally develop against the current stable release of the l
|
|||||||
|
|
||||||
In this directory (`bskyweb/`):
|
In this directory (`bskyweb/`):
|
||||||
|
|
||||||
# re-build and run daemon
|
```bash
|
||||||
go run ./cmd/bskyweb serve
|
# re-build and run daemon
|
||||||
|
go run ./cmd/bskyweb serve
|
||||||
|
|
||||||
# build and output a binary
|
# build and output a binary
|
||||||
go build -o bskyweb ./cmd/bskyweb/
|
go build -o bskyweb ./cmd/bskyweb/
|
||||||
|
```
|
||||||
|
|
||||||
The easiest way to configure the daemon is to copy `example.env` to `.env` and
|
The easiest way to configure the daemon is to copy `example.env` to `.env` and
|
||||||
fill in auth values there.
|
fill in auth values there.
|
||||||
|
|||||||
@@ -574,7 +574,10 @@ func (srv *Server) WebPost(c echo.Context) error {
|
|||||||
|
|
||||||
if postView.Embed != nil && !isEmbedHidden {
|
if postView.Embed != nil && !isEmbedHidden {
|
||||||
hasImages := postView.Embed.EmbedImages_View != nil
|
hasImages := postView.Embed.EmbedImages_View != nil
|
||||||
hasMedia := postView.Embed.EmbedRecordWithMedia_View != nil && postView.Embed.EmbedRecordWithMedia_View.Media != nil && postView.Embed.EmbedRecordWithMedia_View.Media.EmbedImages_View != nil
|
hasVideo := postView.Embed.EmbedVideo_View != nil
|
||||||
|
hasMedia := postView.Embed.EmbedRecordWithMedia_View != nil && postView.Embed.EmbedRecordWithMedia_View.Media != nil
|
||||||
|
hasMediaImages := hasMedia && postView.Embed.EmbedRecordWithMedia_View.Media.EmbedImages_View != nil
|
||||||
|
hasMediaVideo := hasMedia && postView.Embed.EmbedRecordWithMedia_View.Media.EmbedVideo_View != nil
|
||||||
|
|
||||||
if hasImages {
|
if hasImages {
|
||||||
var thumbUrls []string
|
var thumbUrls []string
|
||||||
@@ -582,12 +585,20 @@ func (srv *Server) WebPost(c echo.Context) error {
|
|||||||
thumbUrls = append(thumbUrls, postView.Embed.EmbedImages_View.Images[i].Thumb)
|
thumbUrls = append(thumbUrls, postView.Embed.EmbedImages_View.Images[i].Thumb)
|
||||||
}
|
}
|
||||||
data["imgThumbUrls"] = thumbUrls
|
data["imgThumbUrls"] = thumbUrls
|
||||||
} else if hasMedia {
|
} else if hasVideo {
|
||||||
|
if postView.Embed.EmbedVideo_View.Thumbnail != nil {
|
||||||
|
data["imgThumbUrls"] = []string{*postView.Embed.EmbedVideo_View.Thumbnail}
|
||||||
|
}
|
||||||
|
} else if hasMediaImages {
|
||||||
var thumbUrls []string
|
var thumbUrls []string
|
||||||
for i := range postView.Embed.EmbedRecordWithMedia_View.Media.EmbedImages_View.Images {
|
for i := range postView.Embed.EmbedRecordWithMedia_View.Media.EmbedImages_View.Images {
|
||||||
thumbUrls = append(thumbUrls, postView.Embed.EmbedRecordWithMedia_View.Media.EmbedImages_View.Images[i].Thumb)
|
thumbUrls = append(thumbUrls, postView.Embed.EmbedRecordWithMedia_View.Media.EmbedImages_View.Images[i].Thumb)
|
||||||
}
|
}
|
||||||
data["imgThumbUrls"] = thumbUrls
|
data["imgThumbUrls"] = thumbUrls
|
||||||
|
} else if hasMediaVideo {
|
||||||
|
if postView.Embed.EmbedRecordWithMedia_View.Media.EmbedVideo_View.Thumbnail != nil {
|
||||||
|
data["imgThumbUrls"] = []string{*postView.Embed.EmbedRecordWithMedia_View.Media.EmbedVideo_View.Thumbnail}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user