Skip to content

Commit f36187e

Browse files
committed
Add Integration with Locales
1 parent 11d9814 commit f36187e

File tree

24 files changed

+2480
-57
lines changed

24 files changed

+2480
-57
lines changed

package-lock.json

Lines changed: 1911 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"react-dom": "^17 || ^18 || ^19"
4545
},
4646
"dependencies": {
47-
"@localess/js-client": "0.6.1-next.20250409-075652.0"
47+
"@localess/js-client": "0.6.1-next.20250411-201255.0"
4848
},
4949
"devDependencies": {
5050
"@types/react": "18.3.12",

packages/react/src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type React from 'react';
2-
import {loadLocalessSync, LocalessClient, localessClient} from "@localess/js-client";
2+
import {loadLocalessSync, type LocalessClient, localessClient} from "@localess/js-client";
33
import {FONT_BOLD, FONT_NORMAL} from "./console";
4-
import {LocalessOptions} from "./models";
4+
import {type LocalessOptions} from "./models";
55

66
let _client: LocalessClient | undefined = undefined
77
let _components: Record<string, React.ElementType> = {};
@@ -47,9 +47,10 @@ export function isSyncEnabled(): boolean {
4747
}
4848

4949
// Client + Edit
50-
export {llEditable, LocalessClient} from '@localess/js-client'
50+
export {llEditable} from '@localess/js-client'
51+
export type {LocalessClient} from '@localess/js-client'
5152
// Sync
52-
export {LocalessSync, EventToApp, EventCallback, EventToAppType} from '@localess/js-client'
53+
export type {LocalessSync, EventToApp, EventCallback, EventToAppType} from '@localess/js-client'
5354
// Models
5455
export type * from './models';
5556
// Component
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
3+
"spaces": 2,
4+
"generator-cli": {
5+
"version": "7.8.0",
6+
"generators": {
7+
"v3.0": {
8+
"generatorName": "typescript-axios",
9+
"output": "./src/shared/generated/localess",
10+
"glob": "./open-api/localess.json",
11+
"skipValidateSpec": true,
12+
"apiPackage": "api",
13+
"modelPackage": "model",
14+
"additionalProperties": {
15+
"useSingleRequestParameter": true,
16+
"withSeparateModelsAndApi": true
17+
}
18+
}
19+
}
20+
}
21+
}

playgrounds/next15/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"name": "next15",
33
"version": "0.1.0",
44
"private": true,
5+
"type": "module",
56
"scripts": {
67
"dev": "next dev --turbopack",
78
"build": "next build",
89
"start": "next start",
9-
"lint": "next lint"
10+
"lint": "next lint",
11+
"generate:localess": "openapi-generator-cli generate"
1012
},
1113
"dependencies": {
1214
"@localess/react": "0.0.0",
@@ -23,6 +25,7 @@
2325
"tailwindcss": "^4",
2426
"eslint": "^9",
2527
"eslint-config-next": "15.3.0",
26-
"@eslint/eslintrc": "^3"
28+
"@eslint/eslintrc": "^3",
29+
"@openapitools/openapi-generator-cli": "^2.19.1"
2730
}
2831
}

playgrounds/next15/src/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ localessInit({
88
spaceId: "MmaT4DL0kJ6nXIILUcQF",
99
version: "draft",
1010
token: "Y4rvboPnyzVeC7LddEK5",
11-
debug: true
11+
debug: false
1212
})
1313

1414
const geistSans = Geist({
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Link from 'next/link'
2+
3+
export default function NotFound() {
4+
return (
5+
<div>
6+
<h2>Not Found</h2>
7+
<p>Could not find requested resource</p>
8+
<Link href="/">Return Home</Link>
9+
</div>
10+
)
11+
}

playgrounds/next15/src/app/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import {getLocalessClient} from "@localess/react";
1+
import {getLocalessClient, Content} from "@localess/react";
22
import {LOCALES} from "@/utils/locales";
3+
import {Page} from "@/shared/generated/localess";
34

45
export default async function Home({searchParams}: {
56
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
@@ -33,7 +34,7 @@ export default async function Home({searchParams}: {
3334
);
3435
}
3536

36-
export async function fetchData(locale?: string) {
37+
async function fetchData(locale?: string): Promise<Content<Page>> {
3738
const client = getLocalessClient();
38-
return client.getContentBySlug('home', {locale: locale ? locale : undefined});
39+
return client.getContentBySlug<Page>('home', {locale: locale ? locale : undefined});
3940
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
wwwroot/*.js
2+
node_modules
3+
typings
4+
dist
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm

0 commit comments

Comments
 (0)