/
githubmirror
/
wp-calypso
Обзор
Документация
Войти
/
githubmirror
/
wp-calypso
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
client/reader/spaces/controller.tsx
38 строк
1 KB
Lae
Reader Spaces: address spaces by slug in the URL (#112430)
08 июл 2026, 21:44
Не верифицирован
08 июл 2026, 21:44
a54bee2
Код
Авторство
О чём код?
import { isEnabled } from '@automattic/calypso-config'; import page, { type Context } from '@automattic/calypso-router'; import AsyncLoad from 'calypso/components/async-load'; import { getSpacePath, parseSpaceTab } from './routes'; const loadSpacesView = () => import( /* webpackChunkName: "async-load-calypso-reader-spaces-view" */ 'calypso/reader/spaces/view' ).then( ( { SpacesView } ) => ( { default: SpacesView } ) ); function ensureSpacesEnabled(): boolean { if ( ! isEnabled( 'reader/spaces' ) ) { page.redirect( '/reader' ); return false; } return true; } export const spaces = ( context: Context, next: () => void ) => { if ( ! ensureSpacesEnabled() ) { return; } const tab = parseSpaceTab( context.params.tab ); if ( tab === null ) { // Unknown tab slug — send to the space's canonical (feed) path. page.redirect( getSpacePath( context.params.slug ) ); return; } context.primary = ( <AsyncLoad require={ loadSpacesView } placeholder={ null } slug={ context.params.slug } tab={ tab } /> ); next(); };