From bbf23b66eba4b6bb0f5b36db4ea1bb7ef4115c10 Mon Sep 17 00:00:00 2001
From: Wildan Nursahidan <>
Date: Sat, 17 May 2025 20:45:23 +0700
Subject: [PATCH] fix sponsor and footer social
---
app/page.tsx | 9 +++++----
components/Sponsor.tsx | 46 +++++++++++++++++++++++++++++++++++-------
components/footer.tsx | 36 ++++++++++++++++++++++++++++++---
docu.json | 14 +------------
4 files changed, 78 insertions(+), 27 deletions(-)
diff --git a/app/page.tsx b/app/page.tsx
index b2bceb2..5f1b3be 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -49,8 +49,9 @@ export default function Home() {
>
Mulai Tutorial
- {/*
- Read Blog
- */}
+ Subscribe
+
diff --git a/components/Sponsor.tsx b/components/Sponsor.tsx
index c1c5b31..783192d 100644
--- a/components/Sponsor.tsx
+++ b/components/Sponsor.tsx
@@ -1,16 +1,45 @@
-import docuConfig from "@/docu.json";
+import docuData from "@/docu.json";
import Image from "next/image";
import Link from "next/link";
-export function Sponsor() {
- const sponsor = docuConfig.sponsor;
- const item = sponsor?.item;
+// Define types for docu.json
+interface SponsorItem {
+ url: string;
+ image: string;
+ title: string;
+ description?: string;
+}
- if (!item) return null;
+interface DocuConfig {
+ sponsor?: {
+ title?: string;
+ item?: SponsorItem;
+ };
+ navbar: any; // Anda bisa mendefinisikan tipe yang lebih spesifik jika diperlukan
+ footer: any;
+ meta: any;
+ repository: any;
+ routes: any[];
+}
+
+// Type assertion for docu.json
+const docuConfig = docuData as DocuConfig;
+
+export function Sponsor() {
+ // Safely get sponsor data with optional chaining and default values
+ const sponsor = docuConfig?.sponsor || {};
+ const item = sponsor?.item;
+
+ // Return null if required fields are missing
+ if (!item?.url || !item?.image || !item?.title) {
+ return null;
+ }
return (
-
{sponsor.title || "Sponsor"}
+ {sponsor?.title && (
+ {sponsor.title}
+ )}
{item.title}
-
{item.description}
+ {item.description && (
+
{item.description}
+ )}
diff --git a/components/footer.tsx b/components/footer.tsx
index 5dbaeeb..fb4cc21 100644
--- a/components/footer.tsx
+++ b/components/footer.tsx
@@ -1,7 +1,37 @@
import Link from "next/link";
import { ModeToggle } from "@/components/theme-toggle";
-import docuConfig from "@/docu.json";
-import * as LucideIcons from "lucide-react"; // Import all icons
+import docuData from "@/docu.json";
+import * as LucideIcons from "lucide-react";
+
+// Define types for docu.json
+interface SocialItem {
+ name: string;
+ url: string;
+ iconName: string;
+}
+
+interface FooterConfig {
+ copyright: string;
+ social?: SocialItem[];
+}
+
+interface MetaConfig {
+ title: string;
+ description: string;
+ baseURL: string;
+ favicon: string;
+}
+
+interface DocuConfig {
+ footer: FooterConfig;
+ meta: MetaConfig;
+ navbar: any;
+ repository: any;
+ routes: any[];
+}
+
+// Type assertion for docu.json
+const docuConfig = docuData as DocuConfig;
export function Footer() {
const { footer } = docuConfig;
@@ -33,7 +63,7 @@ export function FooterButtons() {
const footer = docuConfig?.footer;
// Jangan render apapun jika tidak ada data sosial
- if (!footer?.social || !Array.isArray(footer.social) || footer.social.length === 0) {
+ if (!footer || !Array.isArray(footer.social) || footer.social.length === 0) {
return null;
}
diff --git a/docu.json b/docu.json
index 0a6a37c..ee8a88c 100644
--- a/docu.json
+++ b/docu.json
@@ -12,19 +12,7 @@
]
},
"footer": {
- "copyright": "Addon Sejoli Pro",
- "social": [
- {
- "name": "Youtube",
- "url": "https://www.youtube.com/@AddonsSejoliPro",
- "iconName": "YoutubeIcon"
- },
- {
- "name": "Website",
- "url": "https://addonsejoli.pro/product",
- "iconName": "RocketIcon"
- }
- ]
+ "copyright": "Addon Sejoli Pro"
},
"meta": {
"baseURL": "https://docs.addonsejoli.pro",