@jhits/plugin-content 0.0.9 → 0.0.11
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/dist/api/handler.js +1 -1
- package/dist/components/TranslationEditor.d.ts.map +1 -1
- package/dist/components/TranslationEditor.js +16 -0
- package/dist/hooks/useLocaleSync.d.ts +10 -0
- package/dist/hooks/useLocaleSync.d.ts.map +1 -0
- package/dist/hooks/useLocaleSync.js +29 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/api/handler.js
CHANGED
|
@@ -19,7 +19,7 @@ export async function POST(req, config) {
|
|
|
19
19
|
if (!locale || !messages) {
|
|
20
20
|
return NextResponse.json({ error: 'Missing locale or messages' }, { status: 400 });
|
|
21
21
|
}
|
|
22
|
-
const localesDir = config.localesDir || path.join(process.cwd(), 'data/locales');
|
|
22
|
+
const localesDir = config.localesDir || process.env.CONTENT_LOCALES_DIR || path.join(process.cwd(), 'data/locales');
|
|
23
23
|
const currentLocaleDir = path.join(localesDir, locale);
|
|
24
24
|
// Ensure locale directory exists
|
|
25
25
|
await fs.mkdir(currentLocaleDir, { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationEditor.d.ts","sourceRoot":"","sources":["../../src/components/TranslationEditor.tsx"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,iBAAiB,
|
|
1
|
+
{"version":3,"file":"TranslationEditor.d.ts","sourceRoot":"","sources":["../../src/components/TranslationEditor.tsx"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,iBAAiB,mDA4SxC"}
|
|
@@ -44,6 +44,19 @@ export default function TranslationEditor() {
|
|
|
44
44
|
}
|
|
45
45
|
checkAuth();
|
|
46
46
|
}, []);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const handleLocaleUpdate = (event) => {
|
|
49
|
+
if (event.detail.locale === locale) {
|
|
50
|
+
setJsonData(event.detail.messages);
|
|
51
|
+
router.refresh();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
window.addEventListener('locale-updated', handleLocaleUpdate);
|
|
55
|
+
return () => window.removeEventListener('locale-updated', handleLocaleUpdate);
|
|
56
|
+
}, [locale, router]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
setJsonData(messages);
|
|
59
|
+
}, [messages]);
|
|
47
60
|
const isAdmin = userData?.role === 'admin' || userData?.role === 'dev';
|
|
48
61
|
const isDev = userData?.role === 'dev';
|
|
49
62
|
const applyFormatting = (path, type) => {
|
|
@@ -118,6 +131,9 @@ export default function TranslationEditor() {
|
|
|
118
131
|
if (res.ok) {
|
|
119
132
|
router.refresh();
|
|
120
133
|
setShowAddForm(false);
|
|
134
|
+
window.dispatchEvent(new CustomEvent('locale-updated', {
|
|
135
|
+
detail: { locale, messages: jsonData }
|
|
136
|
+
}));
|
|
121
137
|
}
|
|
122
138
|
else {
|
|
123
139
|
alert('Fout bij opslaan');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook that syncs locale messages when they're updated by the content editor
|
|
3
|
+
* Use this in any component that displays translated content to auto-update
|
|
4
|
+
* without a page refresh
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const messages = useLocaleSync();
|
|
8
|
+
*/
|
|
9
|
+
export declare function useLocaleSync(): Record<string, any>;
|
|
10
|
+
//# sourceMappingURL=useLocaleSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocaleSync.d.ts","sourceRoot":"","sources":["../../src/hooks/useLocaleSync.ts"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,wBAAgB,aAAa,wBAqB5B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useLocale, useMessages } from 'next-intl';
|
|
4
|
+
/**
|
|
5
|
+
* Hook that syncs locale messages when they're updated by the content editor
|
|
6
|
+
* Use this in any component that displays translated content to auto-update
|
|
7
|
+
* without a page refresh
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const messages = useLocaleSync();
|
|
11
|
+
*/
|
|
12
|
+
export function useLocaleSync() {
|
|
13
|
+
const locale = useLocale();
|
|
14
|
+
const messages = useMessages();
|
|
15
|
+
const [syncedMessages, setSyncedMessages] = useState(messages);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const handleLocaleUpdate = (event) => {
|
|
18
|
+
if (event.detail.locale === locale) {
|
|
19
|
+
setSyncedMessages(event.detail.messages);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
window.addEventListener('locale-updated', handleLocaleUpdate);
|
|
23
|
+
return () => window.removeEventListener('locale-updated', handleLocaleUpdate);
|
|
24
|
+
}, [locale]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setSyncedMessages(messages);
|
|
27
|
+
}, [messages]);
|
|
28
|
+
return syncedMessages;
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export type { ParsedTextProps } from './components/ParsedText';
|
|
|
21
21
|
export { ParserConfigProvider, useParserConfig } from './context/ParserConfigContext';
|
|
22
22
|
export type { ParserConfigProviderProps } from './context/ParserConfigContext';
|
|
23
23
|
export { useParse } from './hooks/useParse';
|
|
24
|
+
export { useLocaleSync } from './hooks/useLocaleSync';
|
|
24
25
|
export { parse } from './utils/parser';
|
|
25
26
|
export { defaultParserConfig } from './utils/parser-config';
|
|
26
27
|
export type { ParserConfig, FormatStyle } from './utils/parser-config';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,kBAAkB;IAC/B,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CA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,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACtF,YAAY,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAG/E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAItD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export { default as ParsedText } from './components/ParsedText';
|
|
|
25
25
|
export { ParserConfigProvider, useParserConfig } from './context/ParserConfigContext';
|
|
26
26
|
// Export hooks
|
|
27
27
|
export { useParse } from './hooks/useParse';
|
|
28
|
+
export { useLocaleSync } from './hooks/useLocaleSync';
|
|
28
29
|
// Export utilities
|
|
29
30
|
// Note: parse() is a client-only function. Use ParsedText component in server components.
|
|
30
31
|
export { parse } from './utils/parser';
|