Skip to content

Boost: Ensure Home URL is always a predefined Cornerstone Page #44275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e8df008
Ensure Homepage is always shown in meta
LiamSarsfield Jul 10, 2025
defafd8
Add predefined Cornerstone Pages list
LiamSarsfield Jul 10, 2025
345e897
changelog
LiamSarsfield Jul 10, 2025
b13173a
Refactor Cornerstone Pages handling and improve validation
LiamSarsfield Jul 11, 2025
832232e
Update translation comments in CornerstonePages component for clarity
LiamSarsfield Jul 11, 2025
7d71e98
Fix CornerstoneTitleSummary to correctly display the number of pages …
LiamSarsfield Jul 11, 2025
a9e3086
Merge remote-tracking branch 'origin/trunk' into update/boost/corners…
kraftbj Jul 16, 2025
aa1797d
Remove homepage from default pages since it is always a predefined
kraftbj Jul 16, 2025
91a990f
Add reference to homepage being always included
kraftbj Jul 16, 2025
d4bd82d
Use homepage as the sitescore source
kraftbj Jul 16, 2025
075d743
Update the title hint text
kraftbj Jul 16, 2025
a621260
Update function name to clarify it only deals with custom pages
kraftbj Jul 16, 2025
c987298
Remove homepage from existing lists
kraftbj Jul 16, 2025
59cc429
Add test for HOG-215
kraftbj Jul 16, 2025
48adf70
Fix always loading default pages even when the list needs to be empty
dilirity Jul 17, 2025
462057c
Fix showing home page if it was from a 3rd party list
dilirity Jul 17, 2025
833fa88
Fix not loading any default pages for free users
dilirity Jul 17, 2025
ce8151f
Fix showing an empty string in rest route for cornerstone pages
dilirity Jul 17, 2025
13b056b
Remove todo
dilirity Jul 17, 2025
6c391fa
Update error text
dilirity Jul 17, 2025
62ee33f
Fix error in tests
dilirity Jul 17, 2025
8d04c5b
Fix tests not respecting permalink structure
dilirity Jul 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Upgraded from '$features/ui/upgraded/upgraded';
import styles from './cornerstone-pages.module.scss';
import { usePremiumFeatures } from '$lib/stores/premium-features';
import { recordBoostEvent } from '$lib/utils/analytics';
import { useCornerstonePages } from './lib/stores/cornerstone-pages';
import { useCustomCornerstonePages } from './lib/stores/cornerstone-pages';
import Prerender from './prerender/prerender';
import { useSingleModuleState } from '$features/module/lib/stores';

Expand Down Expand Up @@ -53,35 +53,22 @@ const CornerstonePages = () => {
};

const CornerstoneTitleSummary = () => {
const [ cornerstonePages ] = useCornerstonePages();
if ( ! cornerstonePages.length ) {
const [ cornerstonePages ] = useCustomCornerstonePages();
if ( ! Array.isArray( cornerstonePages ) ) {
return null;
}

return sprintf(
/* translators: %s is the number of pages in the cornerstone pages list apart from the homepage. */
/* translators: %s is the number of pages in the custom cornerstone pages list. */
__( 'Added: %s', 'jetpack-boost' ),
() => {
const homepage = Jetpack_Boost.site.url.replace( /\/$/, '' );
const hasHomepage = cornerstonePages.includes( homepage );

if ( hasHomepage ) {
if ( cornerstonePages.length > 1 ) {
return sprintf(
/* translators: %d is the number of pages in the cornerstone pages list apart from the homepage. */
_n(
'Homepage + %d page',
'Homepage + %d pages',
cornerstonePages.length - 1,
'jetpack-boost'
),
cornerstonePages.length - 1
);
}
if ( cornerstonePages.length === 0 ) {
return __( 'Homepage', 'jetpack-boost' );
}

return sprintf(
/* translators: %d is the number of pages added to the cornerstone pages list. */
_n( '%d page', '%d pages', cornerstonePages.length, 'jetpack-boost' ),
/* translators: %d is the number of pages in the custom cornerstone pages list. */
_n( 'Homepage + %d page', 'Homepage + %d pages', cornerstonePages.length, 'jetpack-boost' ),
cornerstonePages.length
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from 'zod';
/**
* Hook to get the Cornerstone Pages.
*/
export function useCornerstonePages(): [
export function useCustomCornerstonePages(): [
string[],
( newValue: string[], onSuccessCallback?: () => void ) => void,
] {
Expand All @@ -27,7 +27,9 @@ const CornerstonePagesProperties = z.object( {
max_pages: z.number(),
max_pages_premium: z.number(),
default_pages: z.array( z.string() ),
predefined_pages: z.array( z.string() ),
} );

type CornerstonePagesProperties = z.infer< typeof CornerstonePagesProperties >;

export function useCornerstonePagesProperties(): CornerstonePagesProperties | undefined {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
margin-top: 16px;
}

&.has-error {
.has-error {

textarea {
border-color: var( --red-40 );
Expand Down Expand Up @@ -77,7 +77,7 @@
}

.description {
margin-top: 8px;
margin: 0;
font-size: 14px;
line-height: 1.5;
color: var( --gray-60 );
Expand All @@ -100,6 +100,15 @@
}
}

.predefined-pages {
margin-top: 0;
padding: 0;

li:last-child {
margin-bottom: 0;
}
}

.see-logs-link {
font-size: 16px;
line-height: 1.5;
Expand Down
Loading
Loading