From 45f7b4af50efcff2f1d5191e304459a84c5414c9 Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Thu, 10 Oct 2019 09:50:01 -0400 Subject: [PATCH] always check the homepage for an existing tag --- assets/js/util/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/js/util/index.js b/assets/js/util/index.js index b2570d8d66e..1a4ff70cbda 100644 --- a/assets/js/util/index.js +++ b/assets/js/util/index.js @@ -602,17 +602,17 @@ export const getExistingTag = async ( module ) => { // Add a timestamp for cache-busting. timestamp: Date.now(), }; - let tagFound; - if ( 'secondary' === ampMode ) { + // Always check the homepage regardless of AMP mode. + let tagFound = await scrapeTag( addQueryArgs( homeURL, tagFetchQueryArgs ), module ); + + if ( ! tagFound && 'secondary' === ampMode ) { tagFound = await apiFetch( { path: '/wp/v2/posts?per_page=1' } ).then( // Scrape the first post in AMP mode, if there is one. ( posts ) => posts.slice( 0, 1 ).map( async ( post ) => { return await scrapeTag( addQueryArgs( post.link, { ...tagFetchQueryArgs, amp: 1 } ), module ); } ).pop() ); - } else { - tagFound = await scrapeTag( addQueryArgs( homeURL, tagFetchQueryArgs ), module ); } return Promise.resolve( tagFound || null );