create-nextjs-cms 0.6.8 → 0.6.9

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.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nextjs-cms",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,8 +9,10 @@ import auth from 'nextjs-cms/auth'
9
9
  import { getCMSConfig } from 'nextjs-cms/core'
10
10
  import { I18nProviderClient } from 'nextjs-cms/translations/client'
11
11
  import { resolveLocale, RTL_LOCALES, LOCALE_COOKIE_NAME } from 'nextjs-cms/translations'
12
+ import { getClientDictionaries } from 'nextjs-cms/translations/server'
12
13
  import { redirect } from 'next/navigation'
13
14
  import { AuthLocaleProvider } from './auth-locale-provider'
15
+ import { DirectionProvider } from "@/components/ui/direction"
14
16
 
15
17
  const inter = Inter({
16
18
  subsets: ['latin'],
@@ -31,16 +33,21 @@ export async function generateMetadata(): Promise<Metadata> {
31
33
  }
32
34
 
33
35
  export default async function RootLayout({ children }: { children: React.ReactNode }) {
34
- const session = await auth()
36
+ const [session, cmsConfig] = await Promise.all([
37
+ auth(),
38
+ getCMSConfig(),
39
+ ])
40
+
35
41
  if (session) {
36
42
  redirect('/')
37
43
  }
38
- const cmsConfig = await getCMSConfig()
44
+
39
45
  const { supportedLanguages, fallbackLanguage } = cmsConfig.i18n
40
46
  const cookieStore = await cookies()
41
47
  const cookieLocale = cookieStore.get(LOCALE_COOKIE_NAME)?.value
42
48
  const locale = resolveLocale(cookieLocale, supportedLanguages, fallbackLanguage)
43
49
  const isRTL = RTL_LOCALES.has(locale)
50
+ const dictionaries = getClientDictionaries(supportedLanguages)
44
51
 
45
52
  return (
46
53
  <html lang={locale} dir={isRTL ? 'rtl' : 'ltr'} suppressHydrationWarning>
@@ -50,7 +57,8 @@ export default async function RootLayout({ children }: { children: React.ReactNo
50
57
  isRTL ? cairo.variable : inter.variable,
51
58
  )}
52
59
  >
53
- <I18nProviderClient locale={locale}>
60
+ <DirectionProvider dir={isRTL ? 'rtl' : 'ltr'} direction={isRTL ? 'rtl' : 'ltr'}>
61
+ <I18nProviderClient locale={locale} dictionaries={dictionaries}>
54
62
  <ThemeProvider
55
63
  attribute='class'
56
64
  defaultTheme={cmsConfig.ui.defaultTheme}
@@ -66,6 +74,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
66
74
  </AuthLocaleProvider>
67
75
  </ThemeProvider>
68
76
  </I18nProviderClient>
77
+ </DirectionProvider>
69
78
  </body>
70
79
  </html>
71
80
  )
@@ -8,8 +8,11 @@ import auth from 'nextjs-cms/auth'
8
8
  import { getCMSConfig } from 'nextjs-cms/core'
9
9
  import { I18nProviderClient } from 'nextjs-cms/translations/client'
10
10
  import { resolveLocale, RTL_LOCALES } from 'nextjs-cms/translations'
11
+ import { getClientDictionaries } from 'nextjs-cms/translations/server'
11
12
  import { api, HydrateClient } from 'nextjs-cms/api/trpc/server'
12
13
  import Layout from '@/components/Layout'
14
+ import { redirect } from 'next/navigation'
15
+ import { DirectionProvider } from "@/components/ui/direction"
13
16
 
14
17
  const inter = Inter({
15
18
  subsets: ['latin'],
@@ -30,12 +33,20 @@ export async function generateMetadata(): Promise<Metadata> {
30
33
  }
31
34
 
32
35
  export default async function CMSLayout({ children }: { children: React.ReactNode }) {
33
- const session = await auth()
34
- const cmsConfig = await getCMSConfig()
36
+ const [session, cmsConfig, _] = await Promise.all([
37
+ auth(),
38
+ getCMSConfig(),
39
+ api.navigation.getSidebar.prefetch(),
40
+ ])
41
+
42
+ if (!session) {
43
+ redirect('/auth/login')
44
+ }
45
+
35
46
  const { supportedLanguages, fallbackLanguage } = cmsConfig.i18n
36
- const locale = resolveLocale(session?.user?.locale, supportedLanguages, fallbackLanguage)
47
+ const locale = resolveLocale(session.user.locale, supportedLanguages, fallbackLanguage)
37
48
  const isRTL = RTL_LOCALES.has(locale)
38
- await api.navigation.getSidebar.prefetch()
49
+ const dictionaries = getClientDictionaries(supportedLanguages)
39
50
 
40
51
  return (
41
52
  <html lang={locale} dir={isRTL ? 'rtl' : 'ltr'} suppressHydrationWarning>
@@ -45,7 +56,8 @@ export default async function CMSLayout({ children }: { children: React.ReactNod
45
56
  isRTL ? cairo.variable : inter.variable,
46
57
  )}
47
58
  >
48
- <I18nProviderClient locale={locale}>
59
+ <DirectionProvider dir={isRTL ? 'rtl' : 'ltr'} direction={isRTL ? 'rtl' : 'ltr'}>
60
+ <I18nProviderClient locale={locale} dictionaries={dictionaries}>
49
61
  <ThemeProvider
50
62
  attribute='class'
51
63
  defaultTheme={cmsConfig.ui.defaultTheme}
@@ -59,8 +71,9 @@ export default async function CMSLayout({ children }: { children: React.ReactNod
59
71
  </Layout>
60
72
  </HydrateClient>
61
73
  </Providers>
62
- </ThemeProvider>
63
- </I18nProviderClient>
74
+ </ThemeProvider>
75
+ </I18nProviderClient>
76
+ </DirectionProvider>
64
77
  </body>
65
78
  </html>
66
79
 
@@ -46,7 +46,7 @@ export const config: CMSConfig = {
46
46
  },
47
47
  },
48
48
  i18n: {
49
- supportedLanguages: { ar },
50
- fallbackLanguage: 'ar',
49
+ supportedLanguages: { ar, en },
50
+ fallbackLanguage: 'en',
51
51
  },
52
52
  }
@@ -42,7 +42,6 @@ const formatTimestamp = (value?: Date | string | null) => {
42
42
 
43
43
  export default function Navbar(props: Props) {
44
44
  const t = useI18n()
45
- const { theme, setTheme } = useTheme()
46
45
  const session = useSession()
47
46
  const { toast } = useToast()
48
47
  const locale = session?.data?.user?.locale ?? 'en'
@@ -132,9 +131,8 @@ export default function Navbar(props: Props) {
132
131
  </DropdownMenuTrigger>
133
132
  <DropdownMenuContent
134
133
  sideOffset={12}
135
- align={isRTL ? 'start' : 'end'}
134
+ align={'end'}
136
135
  side='bottom'
137
- alignOffset={isRTL ? 20 : -20}
138
136
  className='w-[400px] max-w-full ring-1 ring-sky-400/80 dark:ring-amber-900'
139
137
  >
140
138
  <DropdownMenuLabel>{t('notifications')}</DropdownMenuLabel>
@@ -225,9 +223,8 @@ export default function Navbar(props: Props) {
225
223
  </DropdownMenuTrigger>
226
224
  <DropdownMenuContent
227
225
  sideOffset={12}
228
- align={isRTL ? 'start' : 'end'}
226
+ align={'end'}
229
227
  side='bottom'
230
- alignOffset={isRTL ? 10 : -10}
231
228
  className='w-56 max-w-full ring-1 ring-sky-400/80 dark:ring-amber-900'
232
229
  >
233
230
  <DropdownMenuLabel>{session.data?.user.name}</DropdownMenuLabel>
@@ -24,6 +24,7 @@ const VariantCard = ({
24
24
  const axiosPrivate = useAxiosPrivate()
25
25
  const controller = new AbortController()
26
26
  const { toast } = useToast()
27
+ const t = useI18n()
27
28
 
28
29
  const handleDelete = async () => {
29
30
  const response = await handleVariantDeletion(variant.variant_name, variantItem.id, axiosPrivate, controller)
@@ -64,7 +64,7 @@ export default function LocalePicker({
64
64
  </button>
65
65
  </DropdownMenuTrigger>
66
66
  <DropdownMenuContent
67
- align={isRTL ? 'start' : 'end'}
67
+ align={'end'}
68
68
  sideOffset={12}
69
69
  className='ring-1 ring-sky-400/80 dark:ring-amber-900'
70
70
  >
@@ -0,0 +1,22 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Direction } from "radix-ui"
5
+
6
+ function DirectionProvider({
7
+ dir,
8
+ direction,
9
+ children,
10
+ }: React.ComponentProps<typeof Direction.DirectionProvider> & {
11
+ direction?: React.ComponentProps<typeof Direction.DirectionProvider>["dir"]
12
+ }) {
13
+ return (
14
+ <Direction.DirectionProvider dir={direction ?? dir}>
15
+ {children}
16
+ </Direction.DirectionProvider>
17
+ )
18
+ }
19
+
20
+ const useDirection = Direction.useDirection
21
+
22
+ export { DirectionProvider, useDirection }
@@ -65,10 +65,11 @@
65
65
  "nanoid": "^5.1.2",
66
66
  "next": "16.1.1",
67
67
  "next-themes": "^0.4.6",
68
- "nextjs-cms": "0.6.8",
68
+ "nextjs-cms": "0.6.9",
69
69
  "plaiceholder": "^3.0.0",
70
70
  "prettier-plugin-tailwindcss": "^0.7.2",
71
71
  "qrcode": "^1.5.4",
72
+ "radix-ui": "^1.4.3",
72
73
  "react": "19.2.3",
73
74
  "react-day-picker": "9.12.0",
74
75
  "react-dom": "19.2.3",
@@ -98,7 +99,7 @@
98
99
  "eslint-config-prettier": "^10.0.1",
99
100
  "eslint-plugin-prettier": "^5.2.3",
100
101
  "fs-extra": "^11.3.3",
101
- "nextjs-cms-kit": "0.6.8",
102
+ "nextjs-cms-kit": "0.6.9",
102
103
  "postcss": "^8.5.1",
103
104
  "prettier": "3.5.0",
104
105
  "raw-loader": "^4.0.2",