Something like shortcodes for Discourse?

AI-generated summary

The discussion revolves around creating a shortcode-like feature in Discourse posts to embed dynamic JavaScript games. j127 discovered MDX, which allows embedding dynamic components in markdown, and wants to implement something similar in Discourse. They envision users embedding a shortcode-like snippet in posts to start games, which would be replaced with a dynamic JavaScript game, saving scores in the database.

j127 found the bbcode plugin and the Topic Template Placeholder Text theme component as potential starting points, as suggested by pfaffman. Additionally, j127 discovered a calendar plugin and a markdown extensions guide that might provide examples and guidance for implementation. They plan to experiment with loading an iframe in a modal and communicating scores using postMessage to embed games in MDX pages on the site.

I recently discovered MDX, which allows you embed dynamic components in markdown using JSX.

I’m wondering how difficult it would be to do something similar in Discourse posts.

I want users to be able to start games in the forum by embedding shortcode-like snippets in posts:

Here's today's game. Let's see who can get the best score.

[game type="whatever" prop2="something" expires="midnight"]

The tag would be replaced with a dynamic JavaScript game. Scores would be saved in the database (or sent into Firebase from the backend).

Does anyone know if something like this exists or if there is an open-source plugin that might provide some ideas on how to implement it?

There is a bbcode plugin and there is the Topic Template Placeholder Text theme component that offer a start, but you’ll need to understand a fair amount about Beginner’s Guide to Creating Discourse Plugins Part 1: Creating a basic plugin

Thanks, I found a calendar plugin that looks like it might have some examples of what I’m looking for (custom markdown tag and some backend controllers). I also found a markdown extensions guide, but haven’t read it closely yet.

If I can load an iframe in a modal, and communicate scores using postMessage, that might allow the games to be embedded in MDX pages on the site too. I’m going to experiment with it.