feat: make blog data dynamic

This commit is contained in:
2025-04-12 13:10:38 +05:30
parent ef61d38753
commit 72cd1a7f47
8 changed files with 370 additions and 181 deletions

16
app/api/blogs/route.js Normal file
View File

@@ -0,0 +1,16 @@
import { NextResponse } from "next/server";
import axios from "axios";
import { backendUrl } from "@/utils/axios";
export async function GET() {
try {
const response = await axios.get(`${backendUrl}/blogs/`);
return NextResponse.json(response.data);
} catch (error) {
console.error("Error fetching blogs:", error);
return NextResponse.json(
{ error: "Failed to fetch blog data" },
{ status: 500 }
);
}
}

View File

@@ -0,0 +1,19 @@
import { NextResponse } from "next/server";
import axios from "axios";
import { backendUrl } from "@/utils/axios";
export async function GET(request, { params }) {
const { slug } = params;
try {
console.log(`API route fetching blog with slug: ${slug}`);
const response = await axios.get(`${backendUrl}/blogs/${slug}/`);
return NextResponse.json(response.data);
} catch (error) {
console.error(`Error fetching blog with slug ${slug}:`, error);
return NextResponse.json(
{ error: `Failed to fetch blog: ${error.message}` },
{ status: error.response?.status || 500 }
);
}
}

View File

@@ -0,0 +1,14 @@
"use client";
import React from "react";
import SingleBlog from "@/components/blog/SingleBlog";
import { useParams } from "next/navigation";
export default function BlogPage() {
const params = useParams();
const slug = params?.["blog-id"];
console.log("BlogPage params:", params);
console.log("BlogPage slug:", slug);
return <SingleBlog slug={slug} />;
}

View File

@@ -2,11 +2,11 @@ export const DASHBOARD = {
"images": [
{
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
{
"id": 2,
"path": "page_images/2.jpg",
"path": "/page_images/2.jpg",
},
],
"heading1": "Explore Gupta Rudraksha",
@@ -19,35 +19,35 @@ export const DASHBOARD = {
"title": "Since 1973",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
"title": "Vedic Energization",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
"title": "Lab Certification",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
"title": "ISO 9001:2015 certified",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
"title": "Secure Payment",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
],
@@ -58,21 +58,21 @@ export const DASHBOARD = {
{
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
"title": "Spirituality",
},
{
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
"title": "Meditation",
},
{
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
"title": "Wellness",
},
@@ -84,11 +84,11 @@ export const DASHBOARD = {
"heading8": "Gupta Rudraksha - The Only Vendor in the World To 100% Lifetime Money Back Authenticity Guarantee.",
"footer_image1": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
"footer_image2": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
}
@@ -112,7 +112,7 @@ export const CONSULTATION = {
"description": "Enhance personal growth, gain clarity, and overcome obstacles.",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -120,7 +120,7 @@ export const CONSULTATION = {
"description": "Scale your business, improve operations, and navigate challenges.",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -128,7 +128,7 @@ export const CONSULTATION = {
"description": "Plan your career, enhance job search strategies, and build professional skills.",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -136,7 +136,7 @@ export const CONSULTATION = {
"description": "Navigate significant life changes and find new directions for personal fulfillment.",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -144,7 +144,7 @@ export const CONSULTATION = {
"description": "Optimize health, wellness, and live a balanced lifestyle.",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -152,7 +152,7 @@ export const CONSULTATION = {
"description": "Resolve conflicts, improve communication, and build healthier relationships.",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -160,7 +160,7 @@ export const CONSULTATION = {
"description": "Optimize finances, plan for retirement, and grow wealth.",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -168,7 +168,7 @@ export const CONSULTATION = {
"description": "Overcome feeling stuck, gain perspective, and find purpose.",
"image": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
],
@@ -179,11 +179,11 @@ export const CONSULTATION = {
"description": "Consultation provides access to expert advice and guidance from professionals who have in-depth knowledge and experience in their respective fields. We can offer valuable insights, strategies, and solutions tailored to your specific needs.",
"image1": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
"image2": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -191,11 +191,11 @@ export const CONSULTATION = {
"description": "Rudraksha experts can recommend specific mantras that align with your spiritual goals and intentions. Mantras are considered powerful tools for spiritual growth, and the right mantra can enhance the effectiveness of your Rudraksha.",
"image1": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
"image2": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -203,11 +203,11 @@ export const CONSULTATION = {
"description": "Rudraksha experts may also have knowledge of Vedic astrology. By analyzing your birth chart, they can provide insights into the planetary influences on your life and suggest Rudraksha combinations that may help balance and harmonize these influences.",
"image1": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
"image2": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -215,11 +215,11 @@ export const CONSULTATION = {
"description": "Understanding the birth charts of family members can offer a holistic view of the energy dynamics within the family. Rudraksha experts can provide guidance on selecting Rudraksha beads that complement the energy of the entire family, fostering a harmonious environment.",
"image1": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
"image2": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -227,11 +227,11 @@ export const CONSULTATION = {
"description": "Understanding the birth charts of family members can offer a holistic view of the energy dynamics within the family. Rudraksha experts can provide guidance on selecting Rudraksha beads that complement the energy of the entire family, fostering a harmonious environment.",
"image1": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
"image2": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
{
@@ -239,11 +239,11 @@ export const CONSULTATION = {
"description": "Understanding the birth charts of family members can offer a holistic view of the energy dynamics within the family. Rudraksha experts can provide guidance on selecting Rudraksha beads that complement the energy of the entire family, fostering a harmonious environment.",
"image1": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
"image2": {
"id": 1,
"path": "page_images/1.jpg",
"path": "/page_images/1.jpg",
},
},
],