Skip to content

Commit

Permalink
Remove general templates from posts
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 committed Jan 18, 2021
1 parent 9df9364 commit 51954f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export const TEMPLATES_GENERAL = [
'front-page',
'home',
'archive',
'singular',
'single',
'single-post',
'index',
'search',
'404',
];

export const TEMPLATES_POSTS = [ 'home', 'single' ];

export const TEMPLATES_NEW_OPTIONS = [
'front-page',
'single-post',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,16 @@ import { map } from 'lodash';
/**
* WordPress dependencies
*/
import {
__experimentalNavigationGroup as NavigationGroup,
__experimentalNavigationMenu as NavigationMenu,
} from '@wordpress/components';
import { __, _x } from '@wordpress/i18n';
import { __experimentalNavigationMenu as NavigationMenu } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import TemplateNavigationItem from '../template-navigation-item';
import {
MENU_TEMPLATES,
MENU_TEMPLATES_POSTS,
TEMPLATES_POSTS,
} from '../constants';
import { MENU_TEMPLATES, MENU_TEMPLATES_POSTS } from '../constants';

export default function TemplatesPostsMenu( { templates } ) {
const generalTemplates =
templates?.filter( ( { slug } ) => TEMPLATES_POSTS.includes( slug ) ) ??
[];
const specificTemplates =
templates?.filter( ( { slug } ) => slug.startsWith( 'post-' ) ) ?? [];

Expand All @@ -34,27 +24,14 @@ export default function TemplatesPostsMenu( { templates } ) {
menu={ MENU_TEMPLATES_POSTS }
title={ __( 'Posts' ) }
parentMenu={ MENU_TEMPLATES }
isEmpty={
generalTemplates.length === 0 && specificTemplates.length === 0
}
isEmpty={ specificTemplates.length === 0 }
>
<NavigationGroup title={ _x( 'Specific', 'specific templates' ) }>
{ map( specificTemplates, ( template ) => (
<TemplateNavigationItem
item={ template }
key={ `wp_template-${ template.id }` }
/>
) ) }
</NavigationGroup>

<NavigationGroup title={ _x( 'General', 'general templates' ) }>
{ map( generalTemplates, ( template ) => (
<TemplateNavigationItem
item={ template }
key={ `wp_template-${ template.id }` }
/>
) ) }
</NavigationGroup>
{ map( specificTemplates, ( template ) => (
<TemplateNavigationItem
item={ template }
key={ `wp_template-${ template.id }` }
/>
) ) }
</NavigationMenu>
);
}

0 comments on commit 51954f9

Please sign in to comment.