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

Snippets: remove all references to getBuilderSearchParams #3954

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions .changeset/brown-avocados-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@builder.io/sdk-angular": patch
"@builder.io/sdk-react-nextjs": patch
"@builder.io/sdk-qwik": patch
"@builder.io/sdk-react": patch
"@builder.io/sdk-react-native": patch
"@builder.io/sdk-solid": patch
"@builder.io/sdk-svelte": patch
"@builder.io/sdk-vue": patch
---

docs: document `getBuilderSearchParams` and `isPreviewing`
8 changes: 1 addition & 7 deletions packages/sdks/e2e/angular-16-ssr/src/app/app.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import type { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';
import {
_processContentResult,
fetchOneEntry,
getBuilderSearchParams,
} from '@builder.io/sdk-angular';
import { _processContentResult, fetchOneEntry } from '@builder.io/sdk-angular';
import { getProps } from '@sdk/tests';

export const appResolver: ResolveFn<any> = (route: ActivatedRouteSnapshot) => {
const urlPath = `/${route.url.join('/')}`;
const searchParams = getBuilderSearchParams(route.queryParams);

return getProps({
pathname: urlPath,
_processContentResult,
options: searchParams,
fetchOneEntry,
});
};
4 changes: 0 additions & 4 deletions packages/sdks/e2e/angular-16/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component } from '@angular/core';
import {
_processContentResult,
fetchOneEntry,
getBuilderSearchParams,
type RegisteredComponent,
} from '@builder.io/sdk-angular';
import { getProps } from '@sdk/tests';
Expand Down Expand Up @@ -62,9 +61,6 @@ export class AppComponent {
const builderProps = await getProps({
pathname: urlPath,
_processContentResult,
options: getBuilderSearchParams(
new URLSearchParams(window.location.search)
),
fetchOneEntry,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Content,
_processContentResult,
fetchOneEntry,
getBuilderSearchParams,
type RegisteredComponent,
} from '@builder.io/sdk-angular';
import { getProps } from '@sdk/tests';
Expand Down Expand Up @@ -94,7 +93,6 @@ export class CatchAllComponent {
const builderProps = await getProps({
pathname: urlPath,
_processContentResult,
options: getBuilderSearchParams(searchParams),
fetchOneEntry: (args) => {
return fetchOneEntry({
...args,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Content,
_processContentResult,
fetchOneEntry,
getBuilderSearchParams,
} from '@builder.io/sdk-react-nextjs';
import { getProps } from '@sdk/tests';
import MyTextBox from '../../components/MyTextBox/MyTextBox';
Expand Down Expand Up @@ -73,7 +72,6 @@ export default async function Page(props: MyPageProps) {
const builderProps = await getProps({
pathname: urlPath,
_processContentResult,
options: getBuilderSearchParams(props.searchParams),
fetchOneEntry,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const useBuilderContentLoader = routeLoader$(async (event) => {

export default component$(() => {
const contentProps = useBuilderContentLoader();

return (
<>
{contentProps.value.addTopPadding && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Content,
_processContentResult,
fetchOneEntry,
getBuilderSearchParams,
} from '@builder.io/sdk-react';
import { getProps } from '@sdk/tests';

Expand Down Expand Up @@ -63,7 +62,6 @@ export default async function Page(props: PageProps) {
const builderProps = await getProps({
pathname: urlPath,
_processContentResult,
options: getBuilderSearchParams(props.searchParams),
fetchOneEntry,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Content,
_processContentResult,
fetchOneEntry,
getBuilderSearchParams,
} from '@builder.io/sdk-react';
import { getProps } from '@sdk/tests';

Expand All @@ -22,7 +21,6 @@ export default async function Page(props: PageProps) {
const builderProps = await getProps({
pathname: urlPath,
_processContentResult,
options: getBuilderSearchParams(await props.searchParams),
fetchOneEntry,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import type { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';
import { fetchOneEntry, getBuilderSearchParams } from '@builder.io/sdk-angular';
import { fetchOneEntry } from '@builder.io/sdk-angular';

export const announcementBarResolver: ResolveFn<any> = (
route: ActivatedRouteSnapshot
) => {
const urlPath = `/${route.url.join('/')}`;
const searchParams = getBuilderSearchParams(route.queryParams);

return fetchOneEntry({
apiKey: 'ee9f13b4981e489a9a1209887695ef2b',
model: 'announcement-bar',
userAttributes: {
urlPath,
},
options: searchParams,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
* snippets/hydrogen/app/components/AnnouncementBarPage.tsx
*/

import {
Content,
fetchOneEntry,
getBuilderSearchParams,
} from '@builder.io/sdk-react';
import {Content, fetchOneEntry} from '@builder.io/sdk-react';
import type {LoaderFunction} from '@remix-run/node';
import {useLoaderData} from '@remix-run/react';
import {useNonce} from '@shopify/hydrogen';
Expand All @@ -29,7 +25,6 @@ export const announcementsLoader: LoaderFunction = async ({
userAttributes: {
urlPath: pathname,
},
options: getBuilderSearchParams(url.searchParams),
});

return {content, model};
Expand Down
1 change: 0 additions & 1 deletion packages/sdks/snippets/hydrogen/app/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const builderLoader: LoaderFunction = async ({params, request}) => {
userAttributes: {
urlPath: pathname,
},
options: getBuilderSearchParams(url.searchParams),
});
return {content, model};
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
isPreviewing,
} from '@builder.io/sdk-react-nextjs';

Expand All @@ -23,7 +22,6 @@ export default async function Page(props: PageProps) {
const urlPath = '/' + (props.params?.slug?.join('/') || '');

const content = await fetchOneEntry({
options: getBuilderSearchParams(props.searchParams),
apiKey: PUBLIC_API_KEY,
model: 'page',
userAttributes: { urlPath },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
isEditing,
isPreviewing,
} from '@builder.io/sdk-react-nextjs';
Expand All @@ -27,7 +26,7 @@ export default async function Page(props: PageProps) {
const content = await fetchOneEntry({
apiKey,
model,
options: getBuilderSearchParams(props.searchParams),

userAttributes: { urlPath },
});

Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/snippets/nuxt/pages/[...app].vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const { data: content } = await useAsyncData(
fetchOneEntry({
model,
apiKey,
options: getBuilderSearchParams(route.query),

userAttributes: { urlPath: route.path },
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const { data: announcement } = await useAsyncData(
fetchOneEntry({
model,
apiKey,
options: getBuilderSearchParams(route.query),

userAttributes: { urlPath: route.path },
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
*/
import { component$ } from '@builder.io/qwik';
import { routeLoader$ } from '@builder.io/qwik-city';
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
} from '@builder.io/sdk-qwik';
import { Content, fetchOneEntry } from '@builder.io/sdk-qwik';

// Define Builder's public API key and content model.
// TO DO: Replace with your Public API Key
Expand All @@ -22,7 +18,6 @@ export const useBuilderContent = routeLoader$(async ({ url }) => {
const builderContent = await fetchOneEntry({
model: BUILDER_MODEL,
apiKey: BUILDER_PUBLIC_API_KEY,
options: getBuilderSearchParams(url.searchParams),
userAttributes: {
urlPath: url.pathname,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { routeLoader$ } from '@builder.io/qwik-city';
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
} from '@builder.io/sdk-qwik';

export const BUILDER_PUBLIC_API_KEY = 'ee9f13b4981e489a9a1209887695ef2b';
Expand All @@ -18,7 +17,7 @@ export const useBuilderContent = routeLoader$(async ({ url }) => {
const announcementBar = await fetchOneEntry({
model: BUILDER_MODEL,
apiKey: BUILDER_PUBLIC_API_KEY,
options: getBuilderSearchParams(url.searchParams),

userAttributes: {
urlPath: url.pathname,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
* snippets/nextjs-app-dir-client/app/[[...slug]].tsx
* Uses @builder.io/sdk-react
*/
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
isPreviewing,
} from '@builder.io/sdk-react';
import { Content, fetchOneEntry, isPreviewing } from '@builder.io/sdk-react';

interface PageProps {
params: {
Expand All @@ -23,7 +18,6 @@ export default async function Page(props: PageProps) {
const urlPath = '/' + (props.params?.slug?.join('/') || '');

const content = await fetchOneEntry({
options: getBuilderSearchParams(props.searchParams),
apiKey: PUBLIC_API_KEY,
model: 'page',
userAttributes: { urlPath },
Expand All @@ -32,12 +26,8 @@ export default async function Page(props: PageProps) {
const canShowContent = content || isPreviewing(props.searchParams);

if (!canShowContent) {
return (
<>
<h1>404</h1>
<p>Make sure you have your content published at Builder.io.</p>
</>
);
return <p>Not Found</p>;
}

return <Content content={content} apiKey={PUBLIC_API_KEY} model="page" />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
isEditing,
isPreviewing,
} from '@builder.io/sdk-react';
Expand All @@ -27,7 +26,6 @@ export default async function Page(props: PageProps) {
const announcementBar = await fetchOneEntry({
apiKey,
model,
options: getBuilderSearchParams(props.searchParams),
userAttributes: { urlPath },
});

Expand Down
2 changes: 0 additions & 2 deletions packages/sdks/snippets/react/src/routes/AnnouncementBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
type BuilderContent,
} from '@builder.io/sdk-react';
import { useEffect, useState } from 'react';
Expand All @@ -24,7 +23,6 @@ export default function AnnouncementBar() {
userAttributes: {
urlPath: window.location.pathname,
},
options: getBuilderSearchParams(new URL(location.href).searchParams),
})
.then((content) => {
if (content) {
Expand Down
2 changes: 0 additions & 2 deletions packages/sdks/snippets/react/src/routes/IntegratingPages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
isPreviewing,
type BuilderContent,
} from '@builder.io/sdk-react';
Expand All @@ -29,7 +28,6 @@ export default function App() {
userAttributes: {
urlPath: window.location.pathname,
},
options: getBuilderSearchParams(new URL(location.href).searchParams),
})
.then((content) => {
if (content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
isPreviewing,
type BuilderContent,
} from '@builder.io/sdk-react';
Expand All @@ -28,7 +27,6 @@ export default function AdvancedChildRoute() {
userAttributes: {
urlPath: window.location.pathname,
},
options: getBuilderSearchParams(new URL(location.href).searchParams),
})
.then((content) => {
if (content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
isPreviewing,
type BuilderContent,
} from '@builder.io/sdk-react';
Expand All @@ -28,7 +27,6 @@ export default function CustomChildRoute() {
userAttributes: {
urlPath: window.location.pathname,
},
options: getBuilderSearchParams(new URL(location.href).searchParams),
})
.then((content) => {
if (content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {
Content,
fetchOneEntry,
getBuilderSearchParams,
isPreviewing,
type BuilderContent,
} from '@builder.io/sdk-react';
Expand All @@ -28,7 +27,6 @@ export default function EditableRegionRoute() {
userAttributes: {
urlPath: window.location.pathname,
},
options: getBuilderSearchParams(new URL(location.href).searchParams),
})
.then((content) => {
if (content) {
Expand Down
Loading
Loading