framework/extensions/embed/extend.php

33 lines
1.0 KiB
PHP
Raw Normal View History

2018-11-16 11:27:38 +08:00
<?php
/*
* This file is part of Flarum.
*
2019-11-30 07:16:58 +08:00
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
2018-11-16 11:27:38 +08:00
*/
use Flarum\Extend;
use Flarum\Frontend\Document;
use Psr\Http\Message\ServerRequestInterface as Request;
return [
(new Extend\Frontend('forum'))
->route(
'/embed/{id:\d+(?:-[^/]*)?}[/{near:[^/]*}]',
'embed.discussion',
function (Document $document, Request $request) {
// Add the discussion content to the document so that the
// payload will be included on the page and the JS app will be
// able to render the discussion immediately.
2021-03-14 06:13:20 +08:00
resolve(Flarum\Forum\Content\Discussion::class)($document, $request);
2018-11-16 11:27:38 +08:00
2021-03-14 06:13:20 +08:00
resolve(Flarum\Frontend\Content\Assets::class)->forFrontend('embed')($document, $request);
2018-11-16 11:27:38 +08:00
}
),
(new Extend\Frontend('embed'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/less/forum.less')
];