Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radhey Radhey: fixes #258

Merged
merged 7 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions public/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/>
<title>
Best Bhagavad Gita App! Download the Gita App now - 100% free | Android,
iPhone, iPad | The Bhagavad Gita App | BhagavadGita.io
iPhone
</title>
<link rel="shortcut icon" href="/app/assets/radhakrishna.png" />
<meta
Expand All @@ -20,7 +20,7 @@
<meta property="og:type" content="website" />
<meta
property="og:title"
content="Best Bhagavad Gita App! Download the Gita App now - 100% free | Android, iPhone, iPad | The Bhagavad Gita App | BhagavadGita.io"
content="Best Bhagavad Gita App! Download the Gita App now - 100% free | Android, iPhone"
/>
<meta
property="og:description"
Expand All @@ -35,7 +35,7 @@
<meta name="twitter:card" content="summary_large_image" />
<meta
name="twitter:title"
content="Best Bhagavad Gita App! Download the Gita App now - 100% free | Android, iPhone, iPad | The Bhagavad Gita App | BhagavadGita.io"
content="Best Bhagavad Gita App! Download the Gita App now - 100% free | Android, iPhone"
/>
<meta
name="twitter:description"
Expand Down
6 changes: 3 additions & 3 deletions src/app/about/[[...locale]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { jsonLdFirst, jsonLdTwo } from "./constants";
export const metadata: Metadata = {
title: "About Bhagavad Gita - BhagavadGita.io",
description:
"Learn about the Bhagavad Gita, a 700-verse Hindu scripture that is part of the epic Mahabharata. Discover its profound wisdom, teachings, and the eternal dialogue between Arjuna and Lord Krishna.",
"Bhagavad Gita is a 700-verse Hindu scripture from Mahabharata containing Lord Krishna's teachings to Arjuna. Discover timeless wisdom on dharma, karma, and spirituality.",
openGraph: {
title: "About Bhagavad Gita - BhagavadGita.io",
description:
"Learn about the Bhagavad Gita, a 700-verse Hindu scripture that is part of the epic Mahabharata. Discover its profound wisdom, teachings, and the eternal dialogue between Arjuna and Lord Krishna.",
"Bhagavad Gita is a 700-verse Hindu scripture from Mahabharata containing Lord Krishna's teachings to Arjuna. Discover timeless wisdom on dharma, karma, and spirituality.",
url: "https://bhagavadgita.io/about",
siteName: "Bhagavad Gita",
locale: "en_US",
Expand All @@ -32,7 +32,7 @@ export const metadata: Metadata = {
card: "summary_large_image",
title: "About Bhagavad Gita - BhagavadGita.io",
description:
"Learn about the Bhagavad Gita, a 700-verse Hindu scripture that is part of the epic Mahabharata. Discover its profound wisdom, teachings, and the eternal dialogue between Arjuna and Lord Krishna.",
"Bhagavad Gita is a 700-verse Hindu scripture from Mahabharata containing Lord Krishna's teachings to Arjuna. Discover timeless wisdom on dharma, karma, and spirituality.",
images: [
"https://bhagavadgita.io/_next/image?url=%2Fbanner2.png&w=3840&q=75",
],
Expand Down
6 changes: 4 additions & 2 deletions src/app/bhagavad-gita-quotes/[[...locale]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { jsonLdFirst, jsonLdTwo } from "./constants";
export const metadata: Metadata = {
title: "Bhagavad Gita Quotes By Krishna - BhagavadGita.io",
description:
"100+ Bhagavad Gita Quotes spoken by Lord Krishna in the Bhagavad Gita to Arjuna on the battlefield of the Kurukshetra.",
"Bhagavad Gita Quotes: 100+ profound sayings by Lord Krishna from the sacred text. Find wisdom on karma, dharma, life, meditation, and spirituality.",
openGraph: {
title: "Bhagavad Gita Quotes By Krishna - BhagavadGita.io",
description:
"100+ Bhagavad Gita Quotes spoken by Lord Krishna in the Bhagavad Gita to Arjuna on the battlefield of the Kurukshetra.",
"Bhagavad Gita Quotes: 100+ profound sayings by Lord Krishna from the sacred text. Find wisdom on karma, dharma, life, meditation, and spirituality.",
url: "https://bhagavadgita.io/bhagavad-gita-quotes",
siteName: "Bhagavad Gita",
images:
Expand All @@ -24,6 +24,8 @@ export const metadata: Metadata = {
twitter: {
card: "summary_large_image",
title: "Bhagavad Gita Quotes By Krishna - BhagavadGita.io",
description:
"Bhagavad Gita Quotes: 100+ profound sayings by Lord Krishna from the sacred text. Find wisdom on karma, dharma, life, meditation, and spirituality.",
images: [
"https://bhagavadgita.io/_next/image?url=%2Fbanner2.png&w=3840&q=75",
],
Expand Down
17 changes: 10 additions & 7 deletions src/app/chapter/[chapterNumber]/(chapter)/[[...locale]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,21 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
return {};
}

// Get first two sentences for description
const sentences =
chapterData.gita_chapters_by_pk.chapter_summary.split(/[.!?]+\s+/);
const chapterDescription = sentences.slice(0, 2).join(". ") + ".";
// Get first sentence and limit to 160 chars
const firstSentence =
chapterData.gita_chapters_by_pk.chapter_summary.split(/[.!?]+\s+/)[0];
const chapterDescription =
firstSentence.length > 157
? firstSentence.slice(0, 157) + "..."
: firstSentence + ".";

const title = isHindi
? `भगवद् गीता अध्याय ${chapterNumber} - ${chapterData.gita_chapters_by_pk.name_translated} - BhagavadGita.io`
: `Bhagavad Gita Chapter ${chapterNumber} - ${chapterData.gita_chapters_by_pk.name_translated} - BhagavadGita.io`;

return {
title,
description: `${chapterDescription}...`,
description: chapterDescription,
openGraph: {
url: isHindi ? `${chapterUrl}/hi` : chapterUrl,
siteName: "Bhagavad Gita",
Expand All @@ -49,7 +52,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
tags: ["Krishna", "Bhagavad Gita", "Bhagwad Gita"],
section: "Bhagavad Gita",
title,
description: `${chapterDescription}...`,
description: chapterDescription,
images: [
{
url: "https://bhagavadgita.io/_next/image?url=%2Fbanner2.png&w=3840&q=75",
Expand All @@ -63,7 +66,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
twitter: {
card: "summary_large_image",
title,
description: `${chapterDescription}...`,
description: chapterDescription,
images: [
"https://bhagavadgita.io/_next/image?url=%2Fbanner2.png&w=3840&q=75",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ export async function generateMetadata({
return {};
}

const verseText = verseData.text.slice(0, 100);
const verseTranslation = verseData.gita_translations[0]?.description?.slice(
0,
100,
);
const description = isHindi
? `भगवद् गीता अध्याय ${chapterNumber} श्लोक ${verseNumber}: ${verseText}... ${verseTranslation}...`
: `Bhagavad Gita Chapter ${chapterNumber} Verse ${verseNumber}: ${verseText}... ${verseTranslation}...`;
// Create description with verse text and translation, limited to 160 chars
const prefix = isHindi
? `भगवद् गीता ${chapterNumber}.${verseNumber}: `
: `Bhagavad Gita ${chapterNumber}.${verseNumber}: `;
const verseText = verseData.text;
const verseTranslation = verseData.gita_translations[0]?.description || "";

// Calculate remaining space after prefix
const remainingSpace = 157 - prefix.length; // 157 to leave room for "..."
const description =
prefix +
(verseText.length > remainingSpace
? verseText.slice(0, remainingSpace) + "..."
: verseText);

const title = isHindi
? `भगवद् गीता अध्याय ${chapterNumber} श्लोक ${verseNumber} - BhagavadGita.io`
Expand Down
6 changes: 3 additions & 3 deletions src/app/gitagpt/[[...locale]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { getJsonLdTwo, jsonLdFirst } from "./constants";
export const metadata: Metadata = {
title: "Bhagavad Gita AI - Gita GPT - Ask Krishna",
description:
"GitaGPT is a free Bhagavad Gita AI chatbot that uses the wisdom of the Bhagavad Gita to help answer your day-to-day questions. It's simple, insightful, and powered by ChatGPT.",
"GitaGPT is a free AI chatbot powered by ChatGPT that provides wisdom from the Bhagavad Gita. Get instant spiritual guidance for your questions through Krishna's teachings.",
openGraph: {
title: "Bhagavad Gita AI - Gita GPT - Ask Krishna",
description:
"GitaGPT is a free Bhagavad Gita AI chatbot that uses the wisdom of the Bhagavad Gita to help answer your day-to-day questions. It's simple, insightful, and powered by ChatGPT.",
"GitaGPT is a free AI chatbot powered by ChatGPT that provides wisdom from the Bhagavad Gita. Get instant spiritual guidance for your questions through Krishna's teachings.",
url: "https://bhagavadgita.io/gitagpt",
siteName: "Bhagavad Gita",
locale: "en_US",
Expand All @@ -30,7 +30,7 @@ export const metadata: Metadata = {
card: "summary_large_image",
title: "Bhagavad Gita AI - Gita GPT - Ask Krishna",
description:
"GitaGPT is a free Bhagavad Gita AI chatbot that uses the wisdom of the Bhagavad Gita to help answer your day-to-day questions. It's simple, insightful, and powered by ChatGPT.",
"GitaGPT is a free AI chatbot powered by ChatGPT that provides wisdom from the Bhagavad Gita. Get instant spiritual guidance for your questions through Krishna's teachings.",
images: [
"https://bhagavadgita.io/_next/image?url=%2Fbanner2.png&w=3840&q=75",
],
Expand Down
13 changes: 7 additions & 6 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { ReactNode } from "react";
import { Metadata } from "next";
import { Inter } from "next/font/google";
import { headers } from "next/headers";
import Script from "next/script";

import TopLoader from "components/Headers/TopLoader";
import { paramsToLocale } from "shared/functions";

import { PreloadResources } from "./preload-resources";
import Providers from "./providers";
Expand Down Expand Up @@ -52,20 +54,19 @@ export const metadata: Metadata = {

export default function RootLayout({ children }: { children: ReactNode }) {
const headersList = headers();
const pathname = headersList.get("x-invoke-path") || "";
const isHindi = pathname.includes("/hi") || pathname === "/hi";
const htmlLang = isHindi ? "hi" : "en";
const requestUrl = headersList.get("x-invoke-path") || "";
const htmlLang = requestUrl.includes("/hi") ? "hi" : "en";

// Log all headers for debugging
console.log("[RootLayout] Path:", pathname);
console.log("[RootLayout] Is Hindi path:", isHindi);
// Log for debugging
console.log("[RootLayout] Request URL:", requestUrl);
console.log("[RootLayout] Using HTML lang:", htmlLang);

return (
<html lang={htmlLang} className={inter.className} suppressHydrationWarning>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Script src="https://p.usestyle.ai" defer />
</head>
<body>
<Providers>
Expand Down
6 changes: 3 additions & 3 deletions src/app/privacy-policy/[[...locale]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import PrivacyTermsBanner from "components/PrivacyTermsBanner";
export const metadata: Metadata = {
title: "Privacy Policy - BhagavadGita.io",
description:
"Our privacy policy outlines how we collect, use, and protect your personal information when you use BhagavadGita.io. Learn about your data rights and our commitment to privacy.",
"Learn how we protect your data, ensure your privacy, and maintain security. Read about data collection, usage, cookies, and your rights.",
openGraph: {
title: "Privacy Policy - BhagavadGita.io",
description:
"Our privacy policy outlines how we collect, use, and protect your personal information when you use BhagavadGita.io. Learn about your data rights and our commitment to privacy.",
"Learn how we protect your data, ensure your privacy, and maintain security. Read about data collection, usage, cookies, and your rights.",
url: "https://bhagavadgita.io/privacy-policy",
siteName: "Bhagavad Gita",
locale: "en_US",
Expand All @@ -28,7 +28,7 @@ export const metadata: Metadata = {
card: "summary_large_image",
title: "Privacy Policy - BhagavadGita.io",
description:
"Our privacy policy outlines how we collect, use, and protect your personal information when you use BhagavadGita.io. Learn about your data rights and our commitment to privacy.",
"Learn how we protect your data, ensure your privacy, and maintain security. Read about data collection, usage, cookies, and your rights.",
images: [
"https://bhagavadgita.io/_next/image?url=%2Fbanner2.png&w=3840&q=75",
],
Expand Down
6 changes: 3 additions & 3 deletions src/app/terms-of-service/[[...locale]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import PrivacyTermsBanner from "components/PrivacyTermsBanner";
export const metadata: Metadata = {
title: "Terms of Service - BhagavadGita.io",
description:
"Read our terms of service to understand the rules, guidelines, and conditions for using BhagavadGita.io. Learn about user responsibilities, copyright policies, and acceptable use.",
"Essential guidelines for using our platform. Read about user responsibilities, content usage, copyright policies, and service terms.",
openGraph: {
title: "Terms of Service - BhagavadGita.io",
description:
"Read our terms of service to understand the rules, guidelines, and conditions for using BhagavadGita.io. Learn about user responsibilities, copyright policies, and acceptable use.",
"Essential guidelines for using our platform. Read about user responsibilities, content usage, copyright policies, and service terms.",
url: "https://bhagavadgita.io/terms-of-service",
siteName: "Bhagavad Gita",
locale: "en_US",
Expand All @@ -28,7 +28,7 @@ export const metadata: Metadata = {
card: "summary_large_image",
title: "Terms of Service - BhagavadGita.io",
description:
"Read our terms of service to understand the rules, guidelines, and conditions for using BhagavadGita.io. Learn about user responsibilities, copyright policies, and acceptable use.",
"Essential guidelines for using our platform. Read about user responsibilities, content usage, copyright policies, and service terms.",
images: [
"https://bhagavadgita.io/_next/image?url=%2Fbanner2.png&w=3840&q=75",
],
Expand Down
26 changes: 16 additions & 10 deletions src/app/verse-of-the-day/[[...locale]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ import VerseOfTheDay from "./VerseOfTheDay";

export async function generateMetadata(): Promise<Metadata> {
return {
title: `Bhagavad Gita - Verse of the Day`,
title: "Bhagavad Gita - Verse of the Day",
description:
"Daily Bhagavad Gita verse with translation & commentary. Get daily spiritual wisdom from Lord Krishna's teachings. Read in Hindi & English for daily inspiration.",
openGraph: {
url: `https://bhagavadgita.io/verse-of-the-day`,
url: "https://bhagavadgita.io/verse-of-the-day",
siteName: "Bhagavad Gita",
locale: "en_US",
type: "article",
authors: "https://www.facebook.com/radhakrishnablog/",
tags: ["Krishna", "Bhagavad Gita", "Bhagwad Gita"],
section: "Bhagavad Gita",
title: `Bhagavad Gita - Verse of the Day`,
title: "Bhagavad Gita - Verse of the Day",
description:
"Daily Bhagavad Gita verse with translation & commentary. Get daily spiritual wisdom from Lord Krishna's teachings. Read in Hindi & English for daily inspiration.",
images: [
{
url: "https://bhagavadgita.io/_next/image?url=%2Fbanner2.png&w=3840&q=75",
Expand All @@ -32,21 +36,23 @@ export async function generateMetadata(): Promise<Metadata> {
},
twitter: {
card: "summary_large_image",
title: `Bhagavad Gita - Verse of the Day`,
title: "Bhagavad Gita - Verse of the Day",
description:
"Daily Bhagavad Gita verse with translation & commentary. Get daily spiritual wisdom from Lord Krishna's teachings. Read in Hindi & English for daily inspiration.",
images: [
"https://bhagavadgita.io/_next/image?url=%2Fbanner2.png&w=3840&q=75",
],
site: "@ShriKrishna",
},
alternates: {
languages: {
en: `https://bhagavadgita.io/verse-of-the-day`,
"en-US": `https://bhagavadgita.io/verse-of-the-day`,
"en-GB": `https://bhagavadgita.io/verse-of-the-day`,
"en-IN": `https://bhagavadgita.io/verse-of-the-day`,
hi: `https://bhagavadgita.io/verse-of-the-day/hi`,
en: "https://bhagavadgita.io/verse-of-the-day",
"en-US": "https://bhagavadgita.io/verse-of-the-day",
"en-GB": "https://bhagavadgita.io/verse-of-the-day",
"en-IN": "https://bhagavadgita.io/verse-of-the-day",
hi: "https://bhagavadgita.io/verse-of-the-day/hi",
},
canonical: `https://bhagavadgita.io/verse-of-the-day`,
canonical: "https://bhagavadgita.io/verse-of-the-day",
},
};
}
Expand Down
5 changes: 3 additions & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ export function middleware(req: NextRequest) {
const anyT = searchT || (typeof cookieT === "string" && cookieT) || "";
const anyC = searchC || (typeof cookieC === "string" && cookieC) || "";

// Determine locale from path and cookie
// More robust locale detection
const pathParts = pathname.split("/").filter(Boolean);
const hasHindiInPath = pathname.includes("/hi") || pathname === "/hi";
const hasHindiInPath =
pathname.includes("/hi") || pathname === "/hi" || pathname.endsWith("/hi");
const isHindiCookie = cookieL === "hi";
const locale = hasHindiInPath || isHindiCookie ? "hi" : "en";

Expand Down
Loading