Today, I added some code to embed topics (the last reply) into the original forums.
At first, I experimented with using a wide range of topic ids and used a random number generator across that range, but many of the posts here at Community do not format so nicely in old forums (not bad, but not perfect), so I decided to go the "selective route" and create a playlist.
If anyone has any topics they would like to see in the embedded playlist
please send me a note or post back. The purpose of the embedded code is to continue to promote visitors to the original site to sign up and post here:
Example 1:
Example 2:
The embedding code from Discourse looks like this:
<div id="discourse-comments"></div>
<script type="text/javascript">
let playlist = [378686, 378653, 378686];
let max = playlist.length - 1;
let index = Math.round(randomNumber(0, max));
DiscourseEmbed = {
discourseUrl: "https://community.unix.com/",
topicId: playlist[index],
};
(function () {
var d = document.createElement("script");
d.type = "text/javascript";
d.async = true;
d.src = DiscourseEmbed.discourseUrl + "javascripts/embed.js";
(
document.getElementsByTagName("head")[0] ||
document.getElementsByTagName("body")[0]
).appendChild(d);
})();
function randomNumber(min, max) {
return Math.random() * (max - min) + min;
}
</script>
In this embedding code, I give extra weight to one topic. We can easily add more topics to the playlist
.
The custom CSS for this code (not yet optimized) to get it to match the original site is:
a.button{
background-color:#0275d8;
border-radius: 4px;
font-size: 0.85em;
font-family: 'Montserrat',sans-serif;
margin-right:20px;
}
span.replies{
color:#170072;
font-family: 'Montserrat',sans-serif;
opacity: 0.7 !important;
}
div.cooked > p > a, #post-1031906 > a{
color:#170072 !important;
font-family: 'Montserrat',sans-serif;
opacity: 0.9 !important;
}
article.post{
font-family: 'Montserrat',sans-serif;
}
span.title{
display:none;
}
div.cooked > h3 > a{
background-color: transparent !important;
color:#170072 !important;
font-family: 'Montserrat',sans-serif !important;
opacity: 0.9 !important;
}
Free free to suggest any topic ids on this forum you would like to see in the embedded code playlist.