Skip to content

Commit 6b8c71d

Browse files
committed
Merge branch 'develop' into trunk
2 parents 2da53ad + 2a70173 commit 6b8c71d

25 files changed

Lines changed: 1098 additions & 25 deletions

File tree

.changeset/itchy-areas-enter.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@headstartwp/core": patch
3+
---
4+
5+
Fix: post path matching logic when params.fullPath is set

.changeset/ninety-lemons-care.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@headstartwp/headstartwp": minor
3+
"@headstartwp/core": minor
4+
---
5+
6+
Introducing optimizeYoastPayload to reduce payload size when using the yoast integration

.changeset/weak-cloths-lose.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@headstartwp/headstartwp": patch
3+
---
4+
5+
Fix how data-wp-block attribute is set to avoid generating incorrect/insecure markup

.github/workflows/nextjs_bundle_analysis-app-router.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
path: ./projects/wp-nextjs-app/.next/analyze/__bundle_analysis.json
5555

5656
- name: Download base branch bundle stats
57-
uses: dawidd6/action-download-artifact@v2
57+
uses: dawidd6/action-download-artifact@v6
5858
if: success() && github.event.number
5959
with:
6060
workflow: nextjs_bundle_analysis.yml

.github/workflows/nextjs_bundle_analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
path: ./projects/wp-nextjs/.next/analyze/__bundle_analysis.json
5555

5656
- name: Download base branch bundle stats
57-
uses: dawidd6/action-download-artifact@v2
57+
uses: dawidd6/action-download-artifact@v6
5858
if: success() && github.event.number
5959
with:
6060
workflow: nextjs_bundle_analysis.yml

docs/documentation/06-WordPress Integration/gutenberg.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ This filter is not as useful as the previous one but it allows you to filter the
4040
/**
4141
* Filter's out the block's attributes after serialization
4242
*
43-
* @param string $encoded_attrs The serialized block's Attributes
43+
* @param string $encoded_attrs The block attributes serialized to a JSON string
4444
* @param array $attrs The Block's Attributes
4545
* @param array $block The Block's schema
4646
* @param \WP_Block $block_instance The block's instance
4747
*/
4848
$block_attrs_serialized = apply_filters(
4949
'tenup_headless_wp_render_blocks_attrs_serialized',
50-
esc_attr( wp_json_encode( $block_attrs ) ),
50+
wp_json_encode( $block_attrs ),
5151
$block_attrs,
5252
$block,
5353
$block_instance

packages/core/src/data/strategies/AbstractFetchStrategy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ export interface EndpointParams {
2828
*/
2929
lang?: string;
3030

31+
/**
32+
* The custom parameter to optimize the Yoast payload.
33+
*
34+
* This is only used if the YoastSEO integration is enabled
35+
*/
36+
optimizeYoastPayload?: boolean;
37+
3138
[k: string]: unknown;
3239
}
3340

packages/core/src/data/strategies/AuthorArchiveFetchStrategy.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getCustomTaxonomies } from '../../utils';
1+
import { getCustomTaxonomies, getSiteBySourceUrl } from '../../utils';
22
import { PostEntity } from '../types';
33
import { authorArchivesMatchers } from '../utils/matchers';
44
import { parsePath } from '../utils/parsePath';
@@ -25,6 +25,10 @@ export class AuthorArchiveFetchStrategy<
2525
const matchers = [...authorArchivesMatchers];
2626
const customTaxonomies = getCustomTaxonomies(this.baseURL);
2727

28+
const config = getSiteBySourceUrl(this.baseURL);
29+
30+
this.optimizeYoastPayload = !!config.integrations?.yoastSEO?.optimizeYoastPayload;
31+
2832
customTaxonomies?.forEach((taxonomy) => {
2933
const slug = taxonomy?.rewrite ?? taxonomy.slug;
3034
matchers.push({

packages/core/src/data/strategies/PostOrPostsFetchStrategy.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from './AbstractFetchStrategy';
99
import { PostParams, SinglePostFetchStrategy } from './SinglePostFetchStrategy';
1010
import { PostsArchiveFetchStrategy, PostsArchiveParams } from './PostsArchiveFetchStrategy';
11-
import { FrameworkError, NotFoundError } from '../../utils';
11+
import { FrameworkError, NotFoundError, getSiteBySourceUrl } from '../../utils';
1212

1313
/**
1414
* The params supported by {@link PostOrPostsFetchStrategy}
@@ -61,11 +61,17 @@ export class PostOrPostsFetchStrategy<
6161

6262
postsStrategy: PostsArchiveFetchStrategy = new PostsArchiveFetchStrategy(this.baseURL);
6363

64+
optimizeYoastPayload: boolean = false;
65+
6466
getDefaultEndpoint(): string {
6567
return '@postOrPosts';
6668
}
6769

6870
getParamsFromURL(path: string, params: Partial<P> = {}): Partial<P> {
71+
const config = getSiteBySourceUrl(this.baseURL);
72+
73+
this.optimizeYoastPayload = !!config.integrations?.yoastSEO?.optimizeYoastPayload;
74+
6975
this.urlParams = {
7076
single: this.postStrategy.getParamsFromURL(path, params.single),
7177
archive: this.postsStrategy.getParamsFromURL(path, params.archive),

packages/core/src/data/strategies/PostsArchiveFetchStrategy.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ export class PostsArchiveFetchStrategy<
211211

212212
locale: string = '';
213213

214+
optimizeYoastPayload: boolean = false;
215+
214216
getDefaultEndpoint(): string {
215217
return endpoints.posts;
216218
}
@@ -234,6 +236,8 @@ export class PostsArchiveFetchStrategy<
234236
this.locale = config.integrations?.polylang?.enable && params.lang ? params.lang : '';
235237
this.path = path;
236238

239+
this.optimizeYoastPayload = !!config.integrations?.yoastSEO?.optimizeYoastPayload;
240+
237241
const matchers = [...postsMatchers];
238242

239243
if (typeof params.taxonomy === 'string') {
@@ -457,6 +461,12 @@ export class PostsArchiveFetchStrategy<
457461
}
458462
}
459463

464+
if (this.optimizeYoastPayload) {
465+
finalUrl = addQueryArgs(finalUrl, {
466+
optimizeYoastPayload: true,
467+
});
468+
}
469+
460470
return super.fetcher(finalUrl, params, options);
461471
}
462472

0 commit comments

Comments
 (0)