deptagency / dept-engineering-blog-ui

dept-engineering-blog-ui.vercel.app
MIT License
1 stars 3 forks source link

Allow for injection of code in post header #72

Closed nring closed 2 years ago

nring commented 2 years ago

The Ghost Admin UI has a section for embedding script tags in both the header and footer. The normal Casper handlebars theme has support for this, but our Next implementation does not. This adds some naive functionality to enable that. The specific use case was for this post: /benchmarking-rust-code-using-criterion-rs so that the author can correctly display math equations. MathML is not supported enough, so a third party library was necessary.

The other option here is to have the author to supply images for the equations. Thoughts on this approach?

vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
dept-engineering-blog-ui ✅ Ready (Inspect) Visit Preview Jun 16, 2022 at 2:37PM (UTC)
nring commented 2 years ago

Blast, I just realized that this doesn't work when the user is linked to the post from the home page - the injected script never runs.

cmdea commented 2 years ago

Blast, I just realized that this doesn't work when the user is linked to the post from the home page - the injected script never runs.

Sorry I didn't notice you were asking for opinions in the original review. Is there any way to avoid this code injection completely? What about the author supplying some styles we could integrate into the project?

nring commented 2 years ago

I think the author supplying images might be the best bet since this is a step above styling. MathML would be the next best option but Chrome and Edge doesn't support it.

cmdea commented 2 years ago

Ok, that sounds fine to me. I'm all for keeping things simple (as long as the SEO isn't super important here)

Just out of curiosity, are there any libraries beyond MathML with better support? Quick google came up with MathJax.

nring commented 2 years ago

Yeah that's exactly the library the author is trying to include via Ghost! I haven't seen how it affects bundle size if we include it in the whole project, but I'd love to figure out a way to make this on a per-post basis in case another author wants to do something similar with a different library.

nring commented 2 years ago

Closing this PR as this solution is just too brittle. I'll ask that the post author supply SVGs as tags