Change the document title according to the title of the main frame.

This commit is contained in:
Jan Böhmer 2022-07-24 15:19:05 +02:00
parent ea6357c259
commit fa5f5bce28
3 changed files with 32 additions and 17 deletions

View file

@ -0,0 +1,12 @@
import { Controller } from '@hotwired/stimulus';
export default class extends Controller {
connect() {
//If we encounter an element with this, then change the title of our document according to data-title
this.changeTitle(this.element.dataset.title);
}
changeTitle(title) {
document.title = title;
}
}