Skip to content

Commit

Permalink
Cms preview (#2664)
Browse files Browse the repository at this point in the history
* add preview params to cms calls

* Remove prefetch for old homepage
  • Loading branch information
TomWoodward authored Aug 21, 2024
1 parent c58cf5c commit 58db8fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/app/helpers/page-data-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<link rel="preconnect" href="https://connect.facebook.net" crossorigin="anonymous">
<link rel="prefetch" href="<%= process.env.API_ORIGIN %>/apps/cms/api/books/?format=json">
<link rel="prefetch" href="<%= process.env.API_ORIGIN %>/apps/cms/api/footer/?format=json">
<link rel="prefetch" href="<%= process.env.API_ORIGIN %>/apps/cms/api/v2/pages/openstax-homepage/?format=json">
<link rel="stylesheet" href="https://ram.openstax.org/osano/osano.css">
<script src="https://cmp.osano.com/AzZqbXTbzhHsU3cv1/68d8e8ae-4024-4489-a000-72766ad284a6/osano.js"></script>
<script src="//script.crazyegg.com/pages/scripts/0084/9271.js" async="async"></script>
Expand Down

0 comments on commit 58db8fb

Please sign in to comment.