Skip to content

Commit

Permalink
Move title and subtitle to dedicated category config
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiucelfilip committed Oct 22, 2024
1 parent 5f5d176 commit 9e8f3a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
9 changes: 9 additions & 0 deletions client/my-sites/plugins/categories/use-categories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const ALLOWED_CATEGORIES = [
'javascript',
'community',
'captcha',
'wpbeginner',
];

export const getCategories: () => Record< string, Category > = () => ( {
Expand Down Expand Up @@ -751,6 +752,14 @@ export const getCategories: () => Record< string, Category > = () => ( {
tags: [ 'captcha', 'invisible captcha', 'nocaptcha', 'CAPTCHA Code', 'anti-spam' ],
preview: [],
},
wpbeginner: {
menu: __( 'WPBeginner' ),
title: __( 'Must-have plugins from WPBeginner' ),
description: __( 'Add the best-loved plugins on WordPress.com' ),
slug: 'wpbeginner',
tags: [ 'wpbeginner', 'Awesome Motive' ],
preview: [],
},
} );

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ const PluginsCategoryResultsPage = ( { category, siteSlug, sites } ) => {

let results = pagination.results;
const categories = useCategories();
let categoryName = categories[ category ]?.title || category;
let categoryDescription = categories[ category ]?.description;

const categoryName = categories[ category ]?.title || category;
const categoryDescription = categories[ category ]?.description;
const translate = useTranslate();

if ( category === 'wpbeginner' ) {
plugins = esPlugins;
isFetching = esIsFetching;
categoryName = translate( 'Must-have plugins from WPBeginner' );
categoryDescription = translate( 'Add the best-loved plugins on WordPress.com' );
results = esPlugins.length;
} else {
plugins = categoryPlugins;
Expand Down
13 changes: 8 additions & 5 deletions client/my-sites/plugins/plugins-discovery-page/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useTranslate } from 'i18n-calypso';
import { useSelector } from 'react-redux';
import { useESPlugin } from 'calypso/data/marketplace/use-es-query';
import HostingActivateStatus from 'calypso/hosting/server-settings/hosting-activate-status';
Expand All @@ -7,6 +6,7 @@ import { TrialAcknowledgeModal } from 'calypso/my-sites/plans/trials/trial-ackno
import { WithOnclickTrialRequest } from 'calypso/my-sites/plans/trials/trial-acknowledge/with-onclick-trial-request';
import { isCompatiblePlugin } from 'calypso/my-sites/plugins/plugin-compatibility';
import { isUserLoggedIn } from 'calypso/state/current-user/selectors';
import { useCategories } from '../categories/use-categories';
import { WPBEGINNER_PLUGINS } from '../constants';
import EducationFooter from '../education-footer';
import CollectionListView from '../plugins-browser/collection-list-view';
Expand Down Expand Up @@ -52,18 +52,21 @@ export const PaidPluginsSection = ( props ) => {
);
};
export const FeaturedWPBeginnerSection = ( props ) => {
const translate = useTranslate();
const category = 'wpbeginner';
const categories = useCategories();

const categoryName = categories[ category ]?.title || category;
const categoryDescription = categories[ category ]?.description;
const { data: plugins = [], isFetching } = useESPlugin( WPBEGINNER_PLUGINS );

return (
<SingleListView
{ ...props }
category="wpbeginner"
category={ category }
plugins={ plugins }
isFetching={ isFetching }
title={ translate( 'Must-have plugins from WPBeginner' ) }
subtitle={ translate( 'Add the best-loved plugins on WordPress.com' ) }
title={ categoryName }
subtitle={ categoryDescription }
/>
);
};
Expand Down

0 comments on commit 9e8f3a0

Please sign in to comment.