create-nextblock 0.0.1
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/bin/create-nextblock.js +997 -0
- package/package.json +25 -0
- package/scripts/sync-template.js +284 -0
- package/templates/nextblock-template/.env.example +37 -0
- package/templates/nextblock-template/.swcrc +30 -0
- package/templates/nextblock-template/README.md +194 -0
- package/templates/nextblock-template/app/(auth-pages)/forgot-password/page.tsx +57 -0
- package/templates/nextblock-template/app/(auth-pages)/layout.tsx +9 -0
- package/templates/nextblock-template/app/(auth-pages)/post-sign-in/page.tsx +28 -0
- package/templates/nextblock-template/app/(auth-pages)/sign-in/page.tsx +67 -0
- package/templates/nextblock-template/app/(auth-pages)/sign-up/page.tsx +70 -0
- package/templates/nextblock-template/app/ToasterProvider.tsx +17 -0
- package/templates/nextblock-template/app/[slug]/PageClientContent.tsx +147 -0
- package/templates/nextblock-template/app/[slug]/page.tsx +145 -0
- package/templates/nextblock-template/app/[slug]/page.utils.ts +183 -0
- package/templates/nextblock-template/app/actions/email.ts +31 -0
- package/templates/nextblock-template/app/actions/formActions.ts +65 -0
- package/templates/nextblock-template/app/actions/languageActions.ts +130 -0
- package/templates/nextblock-template/app/actions/postActions.ts +80 -0
- package/templates/nextblock-template/app/actions.ts +146 -0
- package/templates/nextblock-template/app/api/process-image/route.ts +210 -0
- package/templates/nextblock-template/app/api/revalidate/route.ts +86 -0
- package/templates/nextblock-template/app/api/revalidate-log/route.ts +23 -0
- package/templates/nextblock-template/app/api/upload/presigned-url/route.ts +106 -0
- package/templates/nextblock-template/app/api/upload/proxy/route.ts +84 -0
- package/templates/nextblock-template/app/auth/callback/route.ts +58 -0
- package/templates/nextblock-template/app/blog/[slug]/PostClientContent.tsx +169 -0
- package/templates/nextblock-template/app/blog/[slug]/page.tsx +177 -0
- package/templates/nextblock-template/app/blog/[slug]/page.utils.ts +136 -0
- package/templates/nextblock-template/app/blog/page.tsx +77 -0
- package/templates/nextblock-template/app/cms/CmsClientLayout.tsx +321 -0
- package/templates/nextblock-template/app/cms/blocks/actions.ts +434 -0
- package/templates/nextblock-template/app/cms/blocks/components/BackgroundSelector.tsx +348 -0
- package/templates/nextblock-template/app/cms/blocks/components/BlockEditorArea.tsx +567 -0
- package/templates/nextblock-template/app/cms/blocks/components/BlockEditorModal.tsx +98 -0
- package/templates/nextblock-template/app/cms/blocks/components/BlockTypeCard.tsx +58 -0
- package/templates/nextblock-template/app/cms/blocks/components/BlockTypeSelector.tsx +62 -0
- package/templates/nextblock-template/app/cms/blocks/components/ColumnEditor.tsx +276 -0
- package/templates/nextblock-template/app/cms/blocks/components/DeleteBlockButtonClient.tsx +47 -0
- package/templates/nextblock-template/app/cms/blocks/components/EditableBlock.tsx +182 -0
- package/templates/nextblock-template/app/cms/blocks/components/MediaLibraryModal.tsx +120 -0
- package/templates/nextblock-template/app/cms/blocks/components/SectionConfigPanel.tsx +133 -0
- package/templates/nextblock-template/app/cms/blocks/components/SortableBlockItem.tsx +46 -0
- package/templates/nextblock-template/app/cms/blocks/editors/ButtonBlockEditor.tsx +85 -0
- package/templates/nextblock-template/app/cms/blocks/editors/FormBlockEditor.tsx +182 -0
- package/templates/nextblock-template/app/cms/blocks/editors/HeadingBlockEditor.tsx +111 -0
- package/templates/nextblock-template/app/cms/blocks/editors/ImageBlockEditor.tsx +150 -0
- package/templates/nextblock-template/app/cms/blocks/editors/PostsGridBlockEditor.tsx +79 -0
- package/templates/nextblock-template/app/cms/blocks/editors/SectionBlockEditor.tsx +337 -0
- package/templates/nextblock-template/app/cms/blocks/editors/TextBlockEditor.tsx +81 -0
- package/templates/nextblock-template/app/cms/blocks/editors/VideoEmbedBlockEditor.tsx +64 -0
- package/templates/nextblock-template/app/cms/components/ConfirmationModal.tsx +51 -0
- package/templates/nextblock-template/app/cms/components/ContentLanguageSwitcher.tsx +145 -0
- package/templates/nextblock-template/app/cms/components/CopyContentFromLanguage.tsx +203 -0
- package/templates/nextblock-template/app/cms/components/LanguageFilterSelect.tsx +69 -0
- package/templates/nextblock-template/app/cms/dashboard/page.tsx +247 -0
- package/templates/nextblock-template/app/cms/layout.tsx +10 -0
- package/templates/nextblock-template/app/cms/media/UploadFolderContext.tsx +22 -0
- package/templates/nextblock-template/app/cms/media/[id]/edit/page.tsx +80 -0
- package/templates/nextblock-template/app/cms/media/actions.ts +577 -0
- package/templates/nextblock-template/app/cms/media/components/DeleteMediaButtonClient.tsx +53 -0
- package/templates/nextblock-template/app/cms/media/components/FolderNavigator.tsx +273 -0
- package/templates/nextblock-template/app/cms/media/components/FolderTree.tsx +122 -0
- package/templates/nextblock-template/app/cms/media/components/MediaEditForm.tsx +157 -0
- package/templates/nextblock-template/app/cms/media/components/MediaGridClient.tsx +275 -0
- package/templates/nextblock-template/app/cms/media/components/MediaImage.tsx +70 -0
- package/templates/nextblock-template/app/cms/media/components/MediaPickerDialog.tsx +195 -0
- package/templates/nextblock-template/app/cms/media/components/MediaUploadForm.tsx +362 -0
- package/templates/nextblock-template/app/cms/media/page.tsx +120 -0
- package/templates/nextblock-template/app/cms/navigation/[id]/edit/page.tsx +101 -0
- package/templates/nextblock-template/app/cms/navigation/actions.ts +358 -0
- package/templates/nextblock-template/app/cms/navigation/components/DeleteNavItemButton.tsx +52 -0
- package/templates/nextblock-template/app/cms/navigation/components/NavigationItemForm.tsx +248 -0
- package/templates/nextblock-template/app/cms/navigation/components/NavigationLanguageSwitcher.tsx +132 -0
- package/templates/nextblock-template/app/cms/navigation/components/NavigationMenuDnd.tsx +701 -0
- package/templates/nextblock-template/app/cms/navigation/components/SortableNavItem.tsx +98 -0
- package/templates/nextblock-template/app/cms/navigation/new/page.tsx +26 -0
- package/templates/nextblock-template/app/cms/navigation/page.tsx +102 -0
- package/templates/nextblock-template/app/cms/navigation/utils.ts +51 -0
- package/templates/nextblock-template/app/cms/pages/[id]/edit/EditPageClient.tsx +121 -0
- package/templates/nextblock-template/app/cms/pages/[id]/edit/page.tsx +79 -0
- package/templates/nextblock-template/app/cms/pages/actions.ts +241 -0
- package/templates/nextblock-template/app/cms/pages/components/DeletePageButtonClient.tsx +47 -0
- package/templates/nextblock-template/app/cms/pages/components/PageForm.tsx +253 -0
- package/templates/nextblock-template/app/cms/pages/new/page.tsx +52 -0
- package/templates/nextblock-template/app/cms/pages/page.tsx +232 -0
- package/templates/nextblock-template/app/cms/posts/[id]/edit/page.tsx +183 -0
- package/templates/nextblock-template/app/cms/posts/actions.ts +309 -0
- package/templates/nextblock-template/app/cms/posts/components/DeletePostButtonClient.tsx +55 -0
- package/templates/nextblock-template/app/cms/posts/components/PostForm.tsx +419 -0
- package/templates/nextblock-template/app/cms/posts/new/page.tsx +21 -0
- package/templates/nextblock-template/app/cms/posts/page.tsx +192 -0
- package/templates/nextblock-template/app/cms/revisions/JsonDiffView.tsx +86 -0
- package/templates/nextblock-template/app/cms/revisions/RevisionHistoryButton.tsx +201 -0
- package/templates/nextblock-template/app/cms/revisions/actions.ts +84 -0
- package/templates/nextblock-template/app/cms/revisions/service.ts +344 -0
- package/templates/nextblock-template/app/cms/revisions/utils.ts +127 -0
- package/templates/nextblock-template/app/cms/settings/copyright/actions.ts +68 -0
- package/templates/nextblock-template/app/cms/settings/copyright/components/CopyrightForm.tsx +78 -0
- package/templates/nextblock-template/app/cms/settings/copyright/page.tsx +32 -0
- package/templates/nextblock-template/app/cms/settings/extra-translations/actions.ts +117 -0
- package/templates/nextblock-template/app/cms/settings/extra-translations/page.tsx +216 -0
- package/templates/nextblock-template/app/cms/settings/languages/[id]/edit/page.tsx +77 -0
- package/templates/nextblock-template/app/cms/settings/languages/actions.ts +261 -0
- package/templates/nextblock-template/app/cms/settings/languages/components/DeleteLanguageButton.tsx +76 -0
- package/templates/nextblock-template/app/cms/settings/languages/components/LanguageForm.tsx +167 -0
- package/templates/nextblock-template/app/cms/settings/languages/new/page.tsx +34 -0
- package/templates/nextblock-template/app/cms/settings/languages/page.tsx +156 -0
- package/templates/nextblock-template/app/cms/settings/logos/[id]/edit/page.tsx +19 -0
- package/templates/nextblock-template/app/cms/settings/logos/actions.ts +114 -0
- package/templates/nextblock-template/app/cms/settings/logos/components/LogoForm.tsx +177 -0
- package/templates/nextblock-template/app/cms/settings/logos/new/page.tsx +11 -0
- package/templates/nextblock-template/app/cms/settings/logos/page.tsx +118 -0
- package/templates/nextblock-template/app/cms/settings/logos/types.ts +8 -0
- package/templates/nextblock-template/app/cms/users/[id]/edit/page.tsx +91 -0
- package/templates/nextblock-template/app/cms/users/actions.ts +156 -0
- package/templates/nextblock-template/app/cms/users/components/DeleteUserButton.tsx +71 -0
- package/templates/nextblock-template/app/cms/users/components/UserForm.tsx +138 -0
- package/templates/nextblock-template/app/cms/users/page.tsx +183 -0
- package/templates/nextblock-template/app/favicon.ico +0 -0
- package/templates/nextblock-template/app/globals.css +401 -0
- package/templates/nextblock-template/app/layout.tsx +191 -0
- package/templates/nextblock-template/app/lib/sitemap-utils.ts +68 -0
- package/templates/nextblock-template/app/page.tsx +109 -0
- package/templates/nextblock-template/app/providers.tsx +43 -0
- package/templates/nextblock-template/app/robots.txt/route.ts +19 -0
- package/templates/nextblock-template/app/sitemap.xml/route.ts +63 -0
- package/templates/nextblock-template/app/unauthorized/page.tsx +27 -0
- package/templates/nextblock-template/backup/backup_2025-06-19.sql +8057 -0
- package/templates/nextblock-template/backup/backup_2025-06-20.sql +8159 -0
- package/templates/nextblock-template/backup/backup_2025-07-08.sql +8411 -0
- package/templates/nextblock-template/backup/backup_2025-07-09.sql +8442 -0
- package/templates/nextblock-template/backup/backup_2025-07-10.sql +8442 -0
- package/templates/nextblock-template/backup/backup_2025-10-01.sql +8803 -0
- package/templates/nextblock-template/backup/backup_2025-10-02.sql +9749 -0
- package/templates/nextblock-template/components/BlockRenderer.tsx +119 -0
- package/templates/nextblock-template/components/FooterNavigation.tsx +33 -0
- package/templates/nextblock-template/components/Header.tsx +42 -0
- package/templates/nextblock-template/components/HtmlScriptExecutor.tsx +47 -0
- package/templates/nextblock-template/components/LanguageSwitcher.tsx +103 -0
- package/templates/nextblock-template/components/ResponsiveNav.tsx +372 -0
- package/templates/nextblock-template/components/blocks/PostCardSkeleton.tsx +17 -0
- package/templates/nextblock-template/components/blocks/PostsGridBlock.tsx +93 -0
- package/templates/nextblock-template/components/blocks/PostsGridClient.tsx +180 -0
- package/templates/nextblock-template/components/blocks/renderers/ButtonBlockRenderer.tsx +92 -0
- package/templates/nextblock-template/components/blocks/renderers/ClientTextBlockRenderer.tsx +69 -0
- package/templates/nextblock-template/components/blocks/renderers/FormBlockRenderer.tsx +98 -0
- package/templates/nextblock-template/components/blocks/renderers/HeadingBlockRenderer.tsx +41 -0
- package/templates/nextblock-template/components/blocks/renderers/HeroBlockRenderer.tsx +240 -0
- package/templates/nextblock-template/components/blocks/renderers/ImageBlockRenderer.tsx +79 -0
- package/templates/nextblock-template/components/blocks/renderers/PostsGridBlockRenderer.tsx +33 -0
- package/templates/nextblock-template/components/blocks/renderers/SectionBlockRenderer.tsx +189 -0
- package/templates/nextblock-template/components/blocks/renderers/TextBlockRenderer.tsx +31 -0
- package/templates/nextblock-template/components/blocks/renderers/VideoEmbedBlockRenderer.tsx +59 -0
- package/templates/nextblock-template/components/blocks/renderers/inline/AlertWidgetRenderer.tsx +51 -0
- package/templates/nextblock-template/components/blocks/renderers/inline/CtaWidgetRenderer.tsx +40 -0
- package/templates/nextblock-template/components/blocks/types.ts +8 -0
- package/templates/nextblock-template/components/env-var-warning.tsx +33 -0
- package/templates/nextblock-template/components/form-message.tsx +26 -0
- package/templates/nextblock-template/components/header-auth.tsx +71 -0
- package/templates/nextblock-template/components/submit-button.tsx +23 -0
- package/templates/nextblock-template/components/theme-switcher.tsx +78 -0
- package/templates/nextblock-template/context/AuthContext.tsx +138 -0
- package/templates/nextblock-template/context/CurrentContentContext.tsx +42 -0
- package/templates/nextblock-template/context/LanguageContext.tsx +206 -0
- package/templates/nextblock-template/docs/cms-application-overview.md +56 -0
- package/templates/nextblock-template/docs/cms-architecture-overview.md +73 -0
- package/templates/nextblock-template/docs/files-structure.md +426 -0
- package/templates/nextblock-template/docs/tiptap-bundle-optimization-summary.md +174 -0
- package/templates/nextblock-template/eslint.config.mjs +28 -0
- package/templates/nextblock-template/index.d.ts +5 -0
- package/templates/nextblock-template/lib/blocks/README.md +670 -0
- package/templates/nextblock-template/lib/blocks/blockRegistry.ts +1001 -0
- package/templates/nextblock-template/lib/ui/ColorPicker.ts +1 -0
- package/templates/nextblock-template/lib/ui/ConfirmationDialog.ts +1 -0
- package/templates/nextblock-template/lib/ui/CustomSelectWithInput.ts +1 -0
- package/templates/nextblock-template/lib/ui/Skeleton.ts +1 -0
- package/templates/nextblock-template/lib/ui/avatar.ts +1 -0
- package/templates/nextblock-template/lib/ui/badge.ts +1 -0
- package/templates/nextblock-template/lib/ui/button.ts +1 -0
- package/templates/nextblock-template/lib/ui/card.ts +1 -0
- package/templates/nextblock-template/lib/ui/checkbox.ts +1 -0
- package/templates/nextblock-template/lib/ui/dialog.ts +1 -0
- package/templates/nextblock-template/lib/ui/dropdown-menu.ts +1 -0
- package/templates/nextblock-template/lib/ui/input.ts +1 -0
- package/templates/nextblock-template/lib/ui/label.ts +1 -0
- package/templates/nextblock-template/lib/ui/popover.ts +1 -0
- package/templates/nextblock-template/lib/ui/progress.ts +1 -0
- package/templates/nextblock-template/lib/ui/select.ts +1 -0
- package/templates/nextblock-template/lib/ui/separator.ts +1 -0
- package/templates/nextblock-template/lib/ui/table.ts +1 -0
- package/templates/nextblock-template/lib/ui/textarea.ts +1 -0
- package/templates/nextblock-template/lib/ui/tooltip.ts +1 -0
- package/templates/nextblock-template/lib/ui/ui.ts +1 -0
- package/templates/nextblock-template/middleware.ts +206 -0
- package/templates/nextblock-template/next-env.d.ts +6 -0
- package/templates/nextblock-template/next.config.js +99 -0
- package/templates/nextblock-template/package.json +52 -0
- package/templates/nextblock-template/postcss.config.js +6 -0
- package/templates/nextblock-template/project.json +7 -0
- package/templates/nextblock-template/public/.gitkeep +0 -0
- package/templates/nextblock-template/scripts/backfill-image-meta.ts +149 -0
- package/templates/nextblock-template/scripts/backup.js +53 -0
- package/templates/nextblock-template/scripts/test-bundle-optimization.js +114 -0
- package/templates/nextblock-template/tailwind.config.ts +19 -0
- package/templates/nextblock-template/tsconfig.json +62 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// app/page.tsx (New Approach)
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { cookies, headers } from 'next/headers'; // Import headers
|
|
4
|
+
import { notFound } from "next/navigation";
|
|
5
|
+
import type { Metadata } from 'next';
|
|
6
|
+
import PageClientContent from "./[slug]/PageClientContent"; // Reuse your existing client content component
|
|
7
|
+
import { getPageDataBySlug } from "./[slug]/page.utils"; // Reuse your existing data fetching utility
|
|
8
|
+
import BlockRenderer from "../components/BlockRenderer"; // Adjust path as needed
|
|
9
|
+
|
|
10
|
+
const DEFAULT_LOCALE = 'en';
|
|
11
|
+
const LANGUAGE_COOKIE_KEY = 'NEXT_USER_LOCALE';
|
|
12
|
+
|
|
13
|
+
// Helper to determine the correct homepage slug based on locale
|
|
14
|
+
async function getHomepageSlugForLocale(locale: string): Promise<string> {
|
|
15
|
+
// This logic assumes you have specific slugs for homepages, e.g., 'home' for 'en', 'accueil' for 'fr'
|
|
16
|
+
// You might fetch this from a 'settings' table or have it hardcoded
|
|
17
|
+
// Your seed data uses 'home' for EN and 'accueil' for FR.
|
|
18
|
+
// The navigation items also link '/' to these specific page IDs.
|
|
19
|
+
// We need to find the page with a specific "home" role/flag or use known slugs.
|
|
20
|
+
|
|
21
|
+
// Option 1: Hardcoded mapping (simplest if slugs are fixed)
|
|
22
|
+
if (locale === 'fr') {
|
|
23
|
+
return 'accueil';
|
|
24
|
+
}
|
|
25
|
+
return 'home'; // Default to English homepage slug
|
|
26
|
+
|
|
27
|
+
// Option 2: Query based on a "is_homepage" flag or a known title/tag in your 'pages' table
|
|
28
|
+
// (This would require schema modification or a convention)
|
|
29
|
+
// const supabase = createClient();
|
|
30
|
+
// const { data, error } = await supabase
|
|
31
|
+
// .from('pages')
|
|
32
|
+
// .select('slug')
|
|
33
|
+
// .eq('language_code', locale) // Assuming you add a language_code column or join with languages
|
|
34
|
+
// .eq('is_homepage_flag', true) // Hypothetical flag
|
|
35
|
+
// .single();
|
|
36
|
+
// if (data?.slug) return data.slug;
|
|
37
|
+
// return locale === 'fr' ? 'accueil' : 'home'; // Fallback
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
41
|
+
const head = await headers();
|
|
42
|
+
let currentLocale = head.get('x-user-locale') || DEFAULT_LOCALE;
|
|
43
|
+
|
|
44
|
+
// Simplified locale detection for metadata
|
|
45
|
+
if (!head.get('x-user-locale')) {
|
|
46
|
+
const cookieStore = await cookies();
|
|
47
|
+
const cookieLocale = cookieStore.get(LANGUAGE_COOKIE_KEY)?.value;
|
|
48
|
+
if (cookieLocale) {
|
|
49
|
+
currentLocale = cookieLocale;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const homepageSlug = await getHomepageSlugForLocale(currentLocale);
|
|
54
|
+
const pageData = await getPageDataBySlug(homepageSlug);
|
|
55
|
+
|
|
56
|
+
if (!pageData) {
|
|
57
|
+
return { title: "Homepage Not Found" };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "";
|
|
61
|
+
|
|
62
|
+
// Simplified metadata without complex hreflang queries for better performance
|
|
63
|
+
return {
|
|
64
|
+
title: pageData.meta_title || pageData.title,
|
|
65
|
+
description: pageData.meta_description || "",
|
|
66
|
+
alternates: {
|
|
67
|
+
canonical: `${siteUrl}/`,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default async function RootPage() {
|
|
73
|
+
|
|
74
|
+
const head = await headers();
|
|
75
|
+
let currentLocale = head.get('x-user-locale') || DEFAULT_LOCALE;
|
|
76
|
+
|
|
77
|
+
// Simplified locale detection - prioritize header/cookie over database query
|
|
78
|
+
if (!head.get('x-user-locale')) {
|
|
79
|
+
const cookieStore = await cookies();
|
|
80
|
+
const cookieLocale = cookieStore.get(LANGUAGE_COOKIE_KEY)?.value;
|
|
81
|
+
if (cookieLocale) {
|
|
82
|
+
currentLocale = cookieLocale;
|
|
83
|
+
}
|
|
84
|
+
// Skip database query for default language - use fallback
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const homepageSlug = await getHomepageSlugForLocale(currentLocale);
|
|
88
|
+
|
|
89
|
+
const pageData = await getPageDataBySlug(homepageSlug);
|
|
90
|
+
|
|
91
|
+
if (!pageData) {
|
|
92
|
+
// This scenario means that for the detected locale, the corresponding homepage slug ('home' or 'accueil')
|
|
93
|
+
// does not exist or is not published.
|
|
94
|
+
// Your seed migration (20250521143933_seed_homepage_and_nav.sql) creates these.
|
|
95
|
+
// Ensure they remain published.
|
|
96
|
+
console.error(`Homepage data not found for slug: ${homepageSlug} (locale: ${currentLocale})`);
|
|
97
|
+
notFound();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const pageBlocks = pageData ? <BlockRenderer blocks={pageData.blocks} languageId={pageData.language_id} /> : null;
|
|
101
|
+
|
|
102
|
+
// Pass currentSlug as homepageSlug to PageClientContent, so it knows what content it's rendering.
|
|
103
|
+
// PageClientContent's logic for language switching will still work if the user changes language via the switcher.
|
|
104
|
+
return (
|
|
105
|
+
<PageClientContent initialPageData={pageData} currentSlug={homepageSlug}>
|
|
106
|
+
{pageBlocks}
|
|
107
|
+
</PageClientContent>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ThemeProvider } from "next-themes";
|
|
4
|
+
import { AuthProvider } from "@/context/AuthContext";
|
|
5
|
+
import { LanguageProvider } from "@/context/LanguageContext";
|
|
6
|
+
import { CurrentContentProvider } from "@/context/CurrentContentContext";
|
|
7
|
+
import { TranslationsProvider } from '@nextblock-cms/utils';
|
|
8
|
+
|
|
9
|
+
export function Providers({ children, ...props }: { children: React.ReactNode;[key: string]: any; }) {
|
|
10
|
+
const {
|
|
11
|
+
serverUser,
|
|
12
|
+
serverProfile,
|
|
13
|
+
serverLocale,
|
|
14
|
+
initialAvailableLanguages,
|
|
15
|
+
initialDefaultLanguage,
|
|
16
|
+
translations,
|
|
17
|
+
nonce
|
|
18
|
+
} = props;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<AuthProvider serverUser={serverUser} serverProfile={serverProfile}>
|
|
22
|
+
<LanguageProvider
|
|
23
|
+
serverLocale={serverLocale}
|
|
24
|
+
initialAvailableLanguages={initialAvailableLanguages}
|
|
25
|
+
initialDefaultLanguage={initialDefaultLanguage}
|
|
26
|
+
>
|
|
27
|
+
<CurrentContentProvider>
|
|
28
|
+
<TranslationsProvider translations={translations} lang={serverLocale}>
|
|
29
|
+
<ThemeProvider
|
|
30
|
+
attribute="class"
|
|
31
|
+
defaultTheme="system"
|
|
32
|
+
enableSystem
|
|
33
|
+
disableTransitionOnChange
|
|
34
|
+
nonce={nonce}
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
</ThemeProvider>
|
|
38
|
+
</TranslationsProvider>
|
|
39
|
+
</CurrentContentProvider>
|
|
40
|
+
</LanguageProvider>
|
|
41
|
+
</AuthProvider>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export async function GET() {
|
|
2
|
+
const siteUrl = process.env.NEXT_PUBLIC_URL || 'http://localhost:3000';
|
|
3
|
+
|
|
4
|
+
if (!process.env.NEXT_PUBLIC_URL) {
|
|
5
|
+
console.warn(
|
|
6
|
+
'Warning: NEXT_PUBLIC_URL environment variable is not set for robots.txt. Defaulting to http://localhost:3000. Ensure this is set for production.'
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const robotsTxtContent = `User-agent: *
|
|
11
|
+
Allow: /
|
|
12
|
+
Sitemap: ${siteUrl}/sitemap.xml`;
|
|
13
|
+
|
|
14
|
+
return new Response(robotsTxtContent, {
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'text/plain',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { fetchAllPublishedPages, fetchAllPublishedPosts } from '../lib/sitemap-utils';
|
|
2
|
+
import { NextResponse } from 'next/server';
|
|
3
|
+
|
|
4
|
+
const baseUrl = process.env.NEXT_PUBLIC_URL || 'http://localhost:3000';
|
|
5
|
+
if (!process.env.NEXT_PUBLIC_URL) {
|
|
6
|
+
console.warn("Warning: NEXT_PUBLIC_URL environment variable is not set for sitemap. Defaulting to http://localhost:3000. Ensure this is set for production.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface SitemapEntry {
|
|
10
|
+
path: string;
|
|
11
|
+
lastModified: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function GET() {
|
|
15
|
+
try {
|
|
16
|
+
let pages: SitemapEntry[] = [];
|
|
17
|
+
try {
|
|
18
|
+
pages = await fetchAllPublishedPages();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error("Error fetching published pages for sitemap:", error);
|
|
21
|
+
// Proceed with an empty array for pages
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let posts: SitemapEntry[] = [];
|
|
25
|
+
try {
|
|
26
|
+
posts = await fetchAllPublishedPosts();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error("Error fetching published posts for sitemap:", error);
|
|
29
|
+
// Proceed with an empty array for posts
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const staticRoutes: SitemapEntry[] = [
|
|
33
|
+
{ path: '/', lastModified: new Date().toISOString() },
|
|
34
|
+
{ path: '/blog', lastModified: new Date().toISOString() },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const allEntries = [...staticRoutes, ...pages, ...posts];
|
|
38
|
+
|
|
39
|
+
const sitemapXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
40
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
41
|
+
${allEntries
|
|
42
|
+
.map(
|
|
43
|
+
(entry) => `
|
|
44
|
+
<url>
|
|
45
|
+
<loc>${baseUrl}${entry.path}</loc>
|
|
46
|
+
<lastmod>${entry.lastModified}</lastmod>
|
|
47
|
+
</url>
|
|
48
|
+
`
|
|
49
|
+
)
|
|
50
|
+
.join('')}
|
|
51
|
+
</urlset>`;
|
|
52
|
+
|
|
53
|
+
return new Response(sitemapXml, {
|
|
54
|
+
headers: {
|
|
55
|
+
'Content-Type': 'application/xml',
|
|
56
|
+
'Cache-Control': 's-maxage=3600, stale-while-revalidate=86400',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error("Error generating sitemap:", error);
|
|
61
|
+
return new NextResponse('Internal Server Error', { status: 500 });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// app/unauthorized/page.tsx
|
|
2
|
+
'use client';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { useSearchParams } from 'next/navigation';
|
|
5
|
+
|
|
6
|
+
export default function UnauthorizedPage() {
|
|
7
|
+
const searchParams = useSearchParams();
|
|
8
|
+
const reason = searchParams.get('reason');
|
|
9
|
+
const error = searchParams.get('error');
|
|
10
|
+
const path = searchParams.get('path');
|
|
11
|
+
const required = searchParams.get('required');
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className="flex flex-col items-center justify-center min-h-screen text-center p-4">
|
|
15
|
+
<h1 className="text-4xl font-bold text-red-600 mb-4">Access Denied</h1>
|
|
16
|
+
<p className="text-xl mb-2">You do not have the necessary permissions to view this page.</p>
|
|
17
|
+
{path && <p className="text-md text-gray-700">Requested path: <code className="bg-gray-200 p-1 rounded">{path}</code></p>}
|
|
18
|
+
{required && <p className="text-md text-gray-700">Required role(s): <code className="bg-gray-200 p-1 rounded">{required.split(',').join(' OR ')}</code></p>}
|
|
19
|
+
{reason && <p className="text-sm text-gray-500 mt-1">Details: {reason}</p>}
|
|
20
|
+
{error && <p className="text-sm text-red-500 mt-1">Error code: {error}</p>}
|
|
21
|
+
<p className="mb-6 mt-4">Please contact your administrator if you believe this is an error.</p>
|
|
22
|
+
<Link href="/" className="px-6 py-3 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors">
|
|
23
|
+
Go to Homepage
|
|
24
|
+
</Link>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|