Skip to content

A platform for community discussion. Free, open, simple.

FIX: Broken hashtags on embed and publish pages (#24210)

Martin Brennan77a009397bda
diff --git a/app/assets/javascripts/discourse/scripts/embed-application.js b/app/assets/javascripts/discourse/scripts/embed-application.js
index 0d231d6b5c3..91df45e79c7 100644
--- a/app/assets/javascripts/discourse/scripts/embed-application.js
+++ b/app/assets/javascripts/discourse/scripts/embed-application.js
@@ -62,5 +62,12 @@
names[i].innerHTML = new BreakString(username).break();
}
}
+
+ // Use a # for hashtags since we don't have the JS and icons needed here to render the proper icon.
+ let hashtags = document.querySelectorAll(".cooked a.hashtag-cooked");
+ for (i = 0; i < hashtags.length; i++) {
+ hashtags[i].querySelector(".hashtag-icon-placeholder .d-icon").remove();
+ hashtags[i].querySelector(".hashtag-icon-placeholder").innerText = "#";
+ }
};
})();
diff --git a/app/assets/javascripts/discourse/scripts/publish.js b/app/assets/javascripts/discourse/scripts/publish.js
new file mode 100644
index 00000000000..78e538d9fa2
--- /dev/null
+++ b/app/assets/javascripts/discourse/scripts/publish.js
@@ -0,0 +1,12 @@
+(function () {
+ window.onload = function () {
+ // Use a # for hashtags since we don't have the JS and icons needed here to render the proper icon.
+ let hashtags = document.querySelectorAll(
+ ".published-page-content-body a.hashtag-cooked"
+ );
+ for (let i = 0; i < hashtags.length; i++) {
+ hashtags[i].querySelector(".hashtag-icon-placeholder .d-icon").remove();
+ hashtags[i].querySelector(".hashtag-icon-placeholder").innerText = "#";
+ }
+ };
+})();
diff --git a/app/assets/stylesheets/embed.scss b/app/assets/stylesheets/embed.scss
index 85d7b15749d..a35d436eab5 100644
--- a/app/assets/stylesheets/embed.scss
+++ b/app/assets/stylesheets/embed.scss
@@ -3,6 +3,7 @@
@import "./common/foundation/base";
@import "./color_definitions";
@import "./common/components/buttons";
+@import "./common/components/hashtag";
article.post {
border-bottom: 1px solid var(--primary-low);
@@ -73,6 +74,15 @@ article.post {
p {
margin: 0 0 1em 0;
}
+
+ .hashtag-cooked {
+ padding: 0.2em 0.5em;
+
+ .hashtag-icon-placeholder {
+ font-weight: bold;
+ margin-right: 0;
+ }
+ }
}
}
diff --git a/app/assets/stylesheets/publish.scss b/app/assets/stylesheets/publish.scss
index 2055ea405b2..e8fe3e237c8 100644
--- a/app/assets/stylesheets/publish.scss
+++ b/app/assets/stylesheets/publish.scss
@@ -81,4 +81,15 @@
max-width: 100%;
height: auto;
}
+
+ .hashtag-cooked {
+ padding: 0.1em 0.5em;
+ font-size: 0.85em;
+
+ .hashtag-icon-placeholder {
+ font-weight: bold;
+ font-size: inherit;
+ margin-right: 0;
+ }
+ }
}
diff --git a/app/views/layouts/publish.html.erb b/app/views/layouts/publish.html.erb
index e0b0c7b1271..04d91c9653f 100644
--- a/app/views/layouts/publish.html.erb
+++ b/app/views/layouts/publish.html.erb
@@ -7,6 +7,7 @@
<%= render partial: "common/discourse_publish_stylesheet" %>
<%= render_google_tag_manager_head_code %>
<%= render_google_universal_analytics_code %>
+ <%= preload_script 'publish' %>
</head>
<body class="<%= @body_classes.to_a.join(' ') %>">
<%= theme_lookup("header") %>