How to insert current topic id to the first post

AI-generated summary

The original poster ddf is trying to embed an iframe in the first post of a topic, with the current topic ID passed as a parameter to the iframe URL. However, Discourse does not provide an easy way to get the current topic ID in the post body.

Bcat suggests using a div with data- attributes and the api.onPageChange event to reverse the iframe, but this approach seems geared towards multiple posts.

ddf clarifies that the requirement is to embed the iframe only in the first post of a topic.

I need to embed a iframe to post, and use current topic ID as variable like this:

<iframe src="https://example.net/iframe?topicid=$"></iframe>

The frame will call some API, so topic ID is required.

I’m trying to get topic ID via URL, but cannot get current URL by header referrer because Discourse do not send full patch referrer (you can pass it by putting some meta tag but mobile Safari doesn’t support the “meta referrer” tag).

Is there another way to automatically put current topic ID to post body?

Thanks.

If it’s for multiple posts then using div with data- then it’s easier to use api.onPageChange + querySelectorAll to reverse the iframe.

Not very clear. I just want to embed on first post of some topic.