Skip to content

Commit 844c96c

Browse files
authored
Merge pull request #638 from google/fix/506-amp-tag-detection
always check the homepage for an existing tag
2 parents 1a2b1e7 + b0bdda6 commit 844c96c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

assets/js/util/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,17 +602,17 @@ export const getExistingTag = async ( module ) => {
602602
// Add a timestamp for cache-busting.
603603
timestamp: Date.now(),
604604
};
605-
let tagFound;
606605

607-
if ( 'secondary' === ampMode ) {
606+
// Always check the homepage regardless of AMP mode.
607+
let tagFound = await scrapeTag( addQueryArgs( homeURL, tagFetchQueryArgs ), module );
608+
609+
if ( ! tagFound && 'secondary' === ampMode ) {
608610
tagFound = await apiFetch( { path: '/wp/v2/posts?per_page=1' } ).then(
609611
// Scrape the first post in AMP mode, if there is one.
610612
( posts ) => posts.slice( 0, 1 ).map( async ( post ) => {
611613
return await scrapeTag( addQueryArgs( post.link, { ...tagFetchQueryArgs, amp: 1 } ), module );
612614
} ).pop()
613615
);
614-
} else {
615-
tagFound = await scrapeTag( addQueryArgs( homeURL, tagFetchQueryArgs ), module );
616616
}
617617

618618
return Promise.resolve( tagFound || null );

0 commit comments

Comments
 (0)