I’m using @eviltrout’s script to display comments on my blog. Everything works fine, but I’d like to tweak the styling a little. As I wasn’t able to find a setting in the admin for the embed css, I was wondering how to best approach this? Any tips?
We unfortunately don’t have a way to customize the style right now.
Is it anywhere on the roadmap? Just being able to add a URL for my own CSS would already be great.
Good question. I wonder if this is something we should squeeze into 1.3 @codinghorror?
I think it’s a great idea. I shared that question (and some round-trip notes) at EvilTrout’s site, here.
I tried a number of methods, and it seems like it might make sense to add something in the embed.js that reads from a local css file or the discourse settings/db and embeds a
<style> element in the
+1 for this,
Thanks for the support Mark! Yes I’m really hoping for some css support as comments on my site look a little off now.
In case you need to style your embedded discourse comments in a blog, here’s what i found/achieved at words.mal
- you can add style to the embed.js (look in /var/lib/docker/aufs/mnt/ and do a find from there)
- the css is like this:
iframe.style.color = ‘#ffffff’;
iframe.style.borderRadius = ‘5px’; /* <<–note the camelCase for hypenated styles */
Make sure to add it before: comments.appendChild(iframe);
- or, you can add css to the embed-49394etc…css file; this is harder. Either add it to the html element, or add to the very end and overwrite with a new style your css.
The obvious downsides of this is it will probably get over written next time you rebuild, but it does work.
For my project of round-trip comment creation and display in an embedded blog, i’m next working on:
- auto-refresh after submitting
- making people have accounts first.
Hope this is useful.
Thanks Mark! I’m a little reluctant to ‘hack’ a solution like that - it getting lost each time I upgrade is a bit of a show stopper. Still hoping for an easy solution in Discourse itself
hi Bart, i’m quite reluctant to ‘hack’ a solution either (and that’s the right word) but i figured it was good to at least have an option on the table for anyone who really needs it.
So, it turns out, the simplest way would be to add this to the headers of the discourse instance that show up on the embedded code:
<script> window.document.domain = "the.domain.name.of.the.blog.com"; </script>
It seems to me that the customized attributes should also flow forward to whatever code gets embedded elsewhere.
Thanks as always.
I don’t know if all of the customized attributes should carry forward to embed code, but I could see adding a section for customizing/injecting css for the embed page. This would likely go a long way towards allowing some nice theming and more seamless integration to the embedding site.
I think this will have to wait until 1.4, as the Ember upgrade and other sysadmin related stuff is much higher priority.
Fair enough Thanks for the reply!
I’d very much like to be able to style comments too. Our forum and blog have very different themes, so embedding looks odd. I’m toying with the idea of using Disqus as a temporary solution, but this is far from ideal
After the switch to rounded avatars in the default theme, there is a mismatch to the embedded comments with the old square avatars even without applying custom styles.
Just checking in if there was any update here? We’re currently using Disqus due to the lack of support for styling, but would love to move back to Discourse if possible.
Yes, actually our latest betas include the ability to style embedded comments in the Admin > Customize > CSS/HTML > Embedding panel.
We use the comments on our blog, and they work so well. (Including the custom Embedding CSS!)
Is there a unique attribute I’ve missed that I can use to hook CSS for one topic’s comments? Or any way that the topic ID can be added to the embedded HTML element in a future release? E.g.