From 58db8fb8ceb743209877ab1ace42793a1c515901 Mon Sep 17 00:00:00 2001 From: Thomas Woodward Date: Wed, 21 Aug 2024 14:06:08 -0400 Subject: [PATCH] Cms preview (#2664) * add preview params to cms calls * Remove prefetch for old homepage --- src/app/helpers/page-data-utils.js | 6 +++++- src/index.html | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/helpers/page-data-utils.js b/src/app/helpers/page-data-utils.js index 488230340..bb659acf9 100644 --- a/src/app/helpers/page-data-utils.js +++ b/src/app/helpers/page-data-utils.js @@ -27,6 +27,10 @@ export function transformData(data) { return data; } +const draftParams = new window.URLSearchParams(window.location.search).has('preview') + ? `&draft=${Date.now()}` + : ''; + export async function getUrlFor(initialSlug) { let apiUrl = urlFromSlug(initialSlug); @@ -46,7 +50,7 @@ export async function getUrlFor(initialSlug) { const qsChar = ((/\?/).test(apiUrl)) ? '&' : '?'; - return `${apiUrl}${qsChar}format=json`; + return `${apiUrl}${qsChar}format=json${draftParams}`; } function camelCase(underscored) { diff --git a/src/index.html b/src/index.html index 852273f36..c3bc5114c 100644 --- a/src/index.html +++ b/src/index.html @@ -24,7 +24,6 @@ -