I'm trying to create a extension that have a new tab on user profile for 'Characters'; I was able to do all that, but instead of having an SPA behavior, where the profile header and sidebar stays while just the content of the page loads, the whole 'main' reloads. It's just a small detail, but since other extensions I added worked perfectly (like Mentions or the Custom Profile Page), I wondered what am I doing wrong.
This is my extensions/cairn-characters/js/src/forum/addCharacterTab.js
import app from 'flarum/forum/app';
import { extend } from 'flarum/common/extend';
import UserPage from 'flarum/forum/components/UserPage';
import LinkButton from 'flarum/common/components/LinkButton';
import CharactersUserPage from './components/CharactersUserPage';
export default function () {
app.routes['user.characters'] = {
path: '/u/:username/characters',
component: CharactersUserPage,
};
extend(UserPage.prototype, 'navItems', function (items) {
const user = this.user;
if (!user) return;
items.add(
'characters',
LinkButton.component(
{
href: app.route('user.characters', { username: user.slug() }),
name: 'characters',
icon: 'fas fa-dragon',
},
app.translator.trans('cairn-characters.forum.nav.characters'),
),
85,
);
});
}
I have the dist also extended for the Frontend, at extend.php:
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/less/forum.less'),
Again, the page works and opens, but does not open as a 'sub page' for Profile.
