Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle sheet params in table block #216

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion blocks/table/table.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
WEB_ORIGINS,
decoratePills, html, isValidDocsURL, isValidWebURL,
} from '../../scripts/scripts.js';

Expand Down Expand Up @@ -58,7 +59,9 @@ async function sheetToDivTable(path) {
}
}

const json = await store.fetchJSON(href);
const url = new URL(href, WEB_ORIGINS[store.env]);
const json = await store.fetchJSON(url.pathname, url.searchParams.getAll('sheet'));

if (!json || !json.data) {
return null;
}
Expand Down
7 changes: 5 additions & 2 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ polyfill();

const range = document.createRange();

export const BRANCH_ORIGIN = 'https://prisma-cloud-docs-production.adobeaem.workers.dev';
// export const BRANCH_ORIGIN = 'http://127.0.0.1:3001';
// export const BRANCH_ORIGIN = 'https://prisma-cloud-docs-production.adobeaem.workers.dev';
export const BRANCH_ORIGIN = 'http://127.0.0.1:3001';

export const SPA_NAVIGATION = true;
export const REDIRECTED_ARTICLE_KEY = 'redirected-article';
Expand Down Expand Up @@ -330,6 +330,9 @@ const store = new (class {
} catch (_) {
url = new URL(`${window.location.origin}${path}.json`);
}
if (url.pathname.endsWith('.json.json')) {
url.pathname = url.pathname.replace(/\.json\.json$/, '.json');
}

if (sheets) {
// eslint-disable-next-line no-param-reassign
Expand Down