dyreschlock / schlock-website

Personal Website code to be run locally or generate a static website hosted through github pages.
http://theschlock.com/
0 stars 0 forks source link

Add Post Previews when posting to Discord, Twitter, etc. #56

Closed dyreschlock closed 1 year ago

dyreschlock commented 1 year ago

When posting links to Twitter and Discord, post previews appear with some information about the link.

Looking online, it seems like this can be done using meta data properties on the HTML head. https://stackoverflow.com/questions/68513906/show-link-preview-i-want-my-link-to-contain-image-title-description-etc

Twitter may have their own unique ones. Don't worry about Facebook.

dyreschlock commented 1 year ago

This is working for the moment. Metadata was added to LayoutBlog, which includes website title, post title, and preview image. Getting the preview is very annoying. For Twitter, if you use the embedded image link from GoogleDrive, everything works just fine. For Discord, it does not.

The GoogleDrive image link does some rerouting before it gets to its final destination and, I guess, Discord doesn't care about that. To resolve this, I'm grabbing the thumbnail GoogleDrive uses when posting it's links on Discord. I have an extra process that will resolve the GoogleDrive file link, read the response, and take the preview link from that page's metadata. I'm saving that link in the database and using that with my posts.

One more problem: This does not work for older images in GoogleDrive. It doesn't work for them in Discord or Twitter either. To get these, I'll probably have to resolve URL referrals until I get to the end of the chain.

Also, there's no guarantee that these thumbnail links will stay active indefinitely.


In other news, I'm not including a description with any of these links. I think having to refit every post with a decent description will take too long, and I don't want the post previews to be too long, either.

dyreschlock commented 1 year ago

I have changed how post previews are being done.

Rather than forcing the site to use Google for its preview images, I'm hosting them directly on github. When Regen'ing pages and such, the cover image will be copied into a /cover directory. The image will be converted to 1024 width, so it won't take up much space. In fact, the complete site does not exceed 200mb for now.

These images are then linked in the metadata which is used to create the previews.

dyreschlock commented 1 year ago

Additional things to consider:

dyreschlock commented 1 year ago

Fixed all of the old posts. From now on, every post that has a gallery should have a cover image.

dyreschlock commented 1 year ago

Ok, I added a description. This is complete.