alessbell / wasm-twitter-card

Create a twitter card-sized image for your blog posts 🖼
https://www.npmjs.com/package/wasm-twitter-card
Apache License 2.0
13 stars 3 forks source link

This is amazing! Now only to figure out how to use it with my js-less Hugo site :) #4

Open jasikpark opened 4 years ago

alessbell commented 4 years ago

Hey, thanks @jasikpark ! I'm not up to speed on the latest state of Go/Wasm interoperability, but it would be super cool if there was a way to do it.

I'm not sure if you've used go-ext-wasm, but I'm wondering if it would be suitable for calling the wasm module in a Hugo build step. The binary is published as wasm_twitter_card_bg.wasm in wasm-twitter-card on npm - don't know if there's a way to distribute wasm binaries for Go consumption specifically but you could use the unpkg CDN to download it directly: https://unpkg.com/wasm-twitter-card@0.3.0/wasm_twitter_card_bg.wasm, no JS required :)

jasikpark commented 4 years ago

ack apparently Hugo doesn't support CGO (c ffi) go modules so I'll probably just include the npm module and use https://gohugo.io/hugo-pipes/ -- I'm already using a template for tailwind+postcss in a couple of my sites, so I guess I'll finally learn how they work!

alessbell commented 4 years ago

Hugo pipes seem pretty powerful, TIL! And feel free to lmk if you run into any issues - it's my first small wasm lib so I'd be curious to debug anything that comes up.

jasikpark commented 4 years ago

Btw, why not just make it a rust binary and support N platforms? Does wasm have nice features instead?

alessbell commented 4 years ago

My use case needed a wasm module so it could be required by a Node.js plugin I wrote for creating open graph images with custom TTF fonts and no native dependencies.

To create a rust binary I think I'd just need to remove wasm-bindgen/serde...