@builder.io/sdk-svelte 0.0.9-1 → 0.0.9-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package/--package.json
CHANGED
|
@@ -3,14 +3,14 @@ import { getBuilderSearchParamsFromWindow, normalizeSearchParams, } from '../get
|
|
|
3
3
|
import { getFetch } from '../get-fetch.js';
|
|
4
4
|
import { handleABTesting } from './ab-testing.js';
|
|
5
5
|
export async function getContent(options) {
|
|
6
|
-
return (await getAllContent({ ...options,
|
|
6
|
+
return (await getAllContent({ ...options, limit: 1 })).results[0] || null;
|
|
7
7
|
}
|
|
8
8
|
export const generateContentUrl = (options) => {
|
|
9
|
-
const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, } = options;
|
|
9
|
+
const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, locale } = options;
|
|
10
10
|
if (!apiKey) {
|
|
11
11
|
throw new Error('Missing API key');
|
|
12
12
|
}
|
|
13
|
-
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}`);
|
|
13
|
+
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}`);
|
|
14
14
|
const queryOptions = {
|
|
15
15
|
...getBuilderSearchParamsFromWindow(),
|
|
16
16
|
...normalizeSearchParams(options.options || {}),
|
|
@@ -32,10 +32,6 @@ export interface GetContentOptions {
|
|
|
32
32
|
* Include references in the response. Defaults to `true`.
|
|
33
33
|
*/
|
|
34
34
|
includeRefs?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Returns a single content match
|
|
37
|
-
*/
|
|
38
|
-
single?: boolean;
|
|
39
35
|
/**
|
|
40
36
|
* If passed , the API will aut-resolve localized objects to the value of this locale key
|
|
41
37
|
*/
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ export type GetContentOptions = import('./types.js').GetContentOptions;
|
|
|
12
12
|
export async function getContent(
|
|
13
13
|
options: GetContentOptions
|
|
14
14
|
): Promise<BuilderContent | null> {
|
|
15
|
-
return (await getAllContent({ ...options,
|
|
15
|
+
return (await getAllContent({ ...options, limit: 1 })).results[0] || null;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
@@ -24,6 +24,7 @@ export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
|
24
24
|
model,
|
|
25
25
|
apiKey,
|
|
26
26
|
includeRefs = true,
|
|
27
|
+
locale
|
|
27
28
|
} = options;
|
|
28
29
|
|
|
29
30
|
if (!apiKey) {
|
|
@@ -31,7 +32,7 @@ export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const url = new URL(
|
|
34
|
-
`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}`
|
|
35
|
+
`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${ locale ? `&locale=${locale}` : ''}`
|
|
35
36
|
);
|
|
36
37
|
|
|
37
38
|
const queryOptions = {
|