How to use `admin_js.admin.embedding.embed_title_scrubber` when custom discourse

(Jerry) #1

When embedding discourse, how to use admin_js.admin.embedding.embed_title_scrubber to customize topic’s title.

Which can provide an example or a related guide?

Embedded discourse topic names
(Jerry) #2

I wrote this, <h1>(.*?)</h1> but did not take effect.

(Jeff Atwood) #3

I believe @eviltrout can comment on this.

(Robin Ward) #4

Any regular expression should work on the title. So <h1>(.*?)</h1> should work fine. Your resulting title still had h1 tags in it?

(Jerry) #5

Yes, I’m sure.

1. Page Sources:

2. Settings in Discouse

(Robin Ward) #7

Are you trying to remove <h1>...</h1>? because the scrubber is designed to replace whatever the regular expression matches with ''.

In that case, your title would be empty.

(Jerry) #8

Sorry, i did not make it clear.
My purpose is discourse to fetch the contents of <h1>xxxx</h1> as the topic name.
The current problem is that although I filled out the correct regular expression, but actually found topic name is still taken from <title>xxxx</title>.

(Robin Ward) #9

There is currently no way to do that. The title scrubber is meant to apply to the title that is returned to remove text that you don’t want. The title has to come from the document.

(Jerry) #10
    <title>This is a title</title>
         <h1>I very much hope that this text becomes the topic</h1>


(Robin Ward) #11

I’m sorry there’s just no way to do that right now. It’s based on the title of the page as I mentioned above. If you’d like to submit a pull request to add this behaviour I’d happily review it!