מודרניזציה של תגים בפנים קוד עבור תבניות ו-JS API

כמנהל של poke and guess קצת דאגתי כשקראתי את זה, אבל כשבדקתי את ערכת הנושא המותאמת אישית שלי, ראיתי רק סקריפט פשוט מאוד:

<script type="text/discourse-plugin" version="0.8.11">

// icon substitutions for share buttons
api.replaceIcon('d-post-share', 'up-right-from-square');
api.replaceIcon('d-topic-share', 'up-right-from-square');


</script>

אז זה היה רק ​​העתק של מה שבין תגיות הסקריפט, קפצתי ללשונית JS, והיה שם מקום להדביק את זה. זה היה קל!

import { apiInitializer } from "discourse/lib/api";

export default apiInitializer((api) => {
	// icon substitutions for share buttons
	api.replaceIcon('d-post-share', 'up-right-from-square');
	api.replaceIcon('d-topic-share', 'up-right-from-square');
});
לייק 1