Skip to content

Commit

Permalink
Merge pull request #100 from wpengine/fix-search-page
Browse files Browse the repository at this point in the history
Add back search relay pagination, remove recent posts from search page
  • Loading branch information
blakewilson committed Nov 9, 2022
2 parents e10a384 + ebc0518 commit 022bc2b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 27 deletions.
14 changes: 1 addition & 13 deletions components/SearchRecommendations/SearchRecommendations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,13 @@ import styles from './SearchRecommendations.module.scss';
* Render the SearchRecommendations component.
*
* @param {Props} props The props object.
* @param {Array} props.recentPosts Array of recent posts from WordPress
* @param {Array} props.categories Array of categories from WordPress
*
* @returns {React.ReactElement} The SearchRecommendations component.
*/
export default function SearchRecommendations({ recentPosts, categories }) {
export default function SearchRecommendations({ categories }) {
return (
<div className={styles.recommendations}>
<h4>Recent Posts</h4>
<ul>
{recentPosts?.map((node) => (
<li key={node.databaseId}>
<Link href={node.uri}>
<a>{node.title}</a>
</Link>
</li>
))}
</ul>

<h4>Browse by Category</h4>
<ul>
{categories?.map((node) => (
Expand Down
15 changes: 1 addition & 14 deletions pages/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default function Page() {
const { title: siteTitle, description: siteDescription } =
pageData.generalSettings;
const primaryMenu = pageData.headerMenuItems.nodes ?? [];
const recentPosts = pageData.posts.nodes;
const categories = pageData.categories.nodes;

const {
Expand Down Expand Up @@ -103,10 +102,7 @@ export default function Page() {
)}

{!searchResultsLoading && searchResultsData === undefined && (
<SearchRecommendations
recentPosts={recentPosts}
categories={categories}
/>
<SearchRecommendations categories={categories} />
)}
</div>
</Main>
Expand Down Expand Up @@ -141,15 +137,6 @@ Page.query = gql`
...NavigationMenuItemFragment
}
}
# Recent Posts
posts(first: 5) {
nodes {
databaseId
uri
title
}
}
# Post Categories
categories {
nodes {
databaseId
Expand Down
1 change: 1 addition & 0 deletions plugins/RelayStylePaginationPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class RelayStylePaginationPlugin {
...options.typePolicies.RootQuery.fields,
posts: relayStylePagination(),
projects: relayStylePagination(),
contentNodes: relayStylePagination(),
},
},
ContentType: {
Expand Down

5 comments on commit 022bc2b

@wp-engine-atlas-development
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the recent updates to your Atlas environment:

App Environment URL Build
atlas-blueprint-portfolio main N/A ❌ (logs)

Learn more about building on Atlas in our documentation.

@atlas-by-wp-engine
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the recent updates to your Atlas environment:

App Environment URL Build
atlas-blueprint-portfolio main https://hd…wered.com ✅ (logs)

Learn more about building on Atlas in our documentation.

@atlas-by-wp-engine
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the recent updates to your Atlas environment:

App Environment URL Build
atlas-bp-portfolio main https://ho…wered.com ✅ (logs)

Learn more about building on Atlas in our documentation.

@wp-engine-atlas-development
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the recent updates to your Atlas environment:

App Environment URL Build
atlas-blueprint-portfolio main N/A ❌ (logs)

Learn more about building on Atlas in our documentation.

@wp-engine-atlas-development
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the recent updates to your Atlas environment:

App Environment URL Build
atlas-blueprint-portfolio main N/A ❌ (logs)

Learn more about building on Atlas in our documentation.

Please sign in to comment.