Skip to content

Commit 002b20b

Browse files
authored
Separate cloud instance functionality (#283)
* Use local URL for SEO * Disable analytics on local instances * Create a dynamic sitemap * move server prop check to server
1 parent 23e8b5c commit 002b20b

5 files changed

Lines changed: 92 additions & 63 deletions

File tree

public/sitemap.xml

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/pages/_app.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Toaster } from 'sonner';
1010
import { ThemeProvider } from '~/components/theme-provider';
1111
import '~/styles/globals.css';
1212
import { LoadingSpinner } from '~/components/ui/spinner';
13+
import { env } from '~/env';
1314
import { type CurrencyCode } from '~/lib/currency';
1415
import { useAddExpenseStore } from '~/store/addStore';
1516
import { useAppStore } from '~/store/appStore';
@@ -52,17 +53,17 @@ const MyApp: AppType<{ session: Session | null }> = ({
5253
<link rel="shortcut icon" href="/favicon.ico" />
5354

5455
<meta name="twitter:card" content="summary" />
55-
<meta name="twitter:url" content="https://splitpro.app" />
56+
<meta name="twitter:url" content={env.NEXTAUTH_URL} />
5657
<meta name="twitter:title" content="SplitPro" />
5758
<meta name="twitter:description" content="Split Expenses with your friends for free" />
58-
<meta name="twitter:image" content="https://splitpro.app/og_banner.png" />
59+
<meta name="twitter:image" content={`${env.NEXTAUTH_URL}/og_banner.png`} />
5960
<meta name="twitter:creator" content="@KM_Koushik_" />
6061
<meta property="og:type" content="website" />
6162
<meta property="og:title" content="SplitPro" />
6263
<meta property="og:description" content="Split Expenses with your friends for free" />
6364
<meta property="og:site_name" content="SplitPro" />
64-
<meta property="og:url" content="https://splitpro.app" />
65-
<meta property="og:image" content="https://splitpro.app/og_banner.png" />
65+
<meta property="og:url" content={env.NEXTAUTH_URL} />
66+
<meta property="og:image" content={`${env.NEXTAUTH_URL}/og_banner.png`} />
6667
</Head>
6768
<SessionProvider session={session}>
6869
<ThemeProvider attribute="class" defaultTheme="dark">

src/pages/balances.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const BalancePage: NextPageWithUser = () => {
2323
.share({
2424
title: 'SplitPro',
2525
text: "Check out SplitPro. It's an open source free alternative for Splitwise",
26-
url: 'https://splitpro.app',
26+
url: window.location.origin,
2727
})
2828
.then(() => console.info('Successful share'))
2929
.catch((error) => console.error('Error sharing', error));

src/pages/home.tsx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,35 @@ import {
1010
Split,
1111
Users,
1212
} from 'lucide-react';
13+
import { type GetServerSideProps } from 'next';
1314
import Head from 'next/head';
1415
import Image from 'next/image';
1516
import Link from 'next/link';
1617

1718
import { BackgroundGradient } from '~/components/ui/background-gradient';
1819
import { Button } from '~/components/ui/button';
20+
import { env } from '~/env';
1921

20-
export default function Home() {
22+
export default function Home({ isCloud }: { isCloud: boolean }) {
2123
return (
2224
<>
23-
<Head>
24-
{process.env.NODE_ENV === 'production' && (
25-
<>
26-
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
27-
<noscript>
28-
{/* eslint-disable-next-line @next/next/no-img-element */}
29-
<img
30-
src="https://queue.simpleanalyticscdn.com/noscript.gif"
31-
alt=""
32-
referrerPolicy="no-referrer-when-downgrade"
33-
/>
34-
</noscript>
35-
</>
36-
)}
37-
</Head>
25+
{isCloud && (
26+
<Head>
27+
{process.env.NODE_ENV === 'production' && (
28+
<>
29+
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
30+
<noscript>
31+
{/* eslint-disable-next-line @next/next/no-img-element */}
32+
<img
33+
src="https://queue.simpleanalyticscdn.com/noscript.gif"
34+
alt=""
35+
referrerPolicy="no-referrer-when-downgrade"
36+
/>
37+
</noscript>
38+
</>
39+
)}
40+
</Head>
41+
)}
3842
<main className="min-h-screen">
3943
<nav className="sticky mx-auto flex max-w-5xl items-center justify-between px-4 py-4 lg:px-0 lg:py-5">
4044
<div className="flex items-center gap-2">
@@ -240,3 +244,9 @@ const MobileScreenShot = () => {
240244
</BackgroundGradient>
241245
);
242246
};
247+
248+
export const getServerSideProps: GetServerSideProps = async () => {
249+
return {
250+
props: { isCloud: env.NEXTAUTH_URL.includes('splitpro.app') },
251+
};
252+
};

src/pages/sitemap.xml.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { type GetServerSideProps } from 'next';
2+
3+
import { env } from '~/env';
4+
5+
const getSitemapXml = (url: string) => `<?xml version="1.0" encoding="UTF-8"?>
6+
<urlset
7+
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
8+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
10+
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
11+
<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->
12+
13+
14+
<url>
15+
<loc>${url}/home</loc>
16+
<lastmod>2025-07-25T08:31:47+00:00</lastmod>
17+
<priority>1.00</priority>
18+
</url>
19+
<url>
20+
<loc>${url}/blog/need-for-splitwise-alternative</loc>
21+
<lastmod>2025-07-25T08:31:47+00:00</lastmod>
22+
<priority>0.80</priority>
23+
</url>
24+
<url>
25+
<loc>${url}/terms</loc>
26+
<lastmod>2025-07-25T08:31:47+00:00</lastmod>
27+
<priority>0.80</priority>
28+
</url>
29+
<url>
30+
<loc>${url}/privacy</loc>
31+
<lastmod>2025-07-25T08:31:47+00:00</lastmod>
32+
<priority>0.80</priority>
33+
</url>
34+
<url>
35+
<loc>${url}/auth/signin</loc>
36+
<lastmod>2025-07-25T08:31:47+00:00</lastmod>
37+
<priority>0.80</priority>
38+
</url>
39+
40+
41+
</urlset>`;
42+
43+
export const getServerSideProps: GetServerSideProps = async ({ res }) => {
44+
// Generate the XML sitemap with the blog data
45+
const sitemap = getSitemapXml(env.NEXTAUTH_URL);
46+
47+
res.setHeader('Content-Type', 'text/xml');
48+
// Send the XML to the browser
49+
res.write(sitemap);
50+
res.end();
51+
52+
return {
53+
props: {},
54+
};
55+
};
56+
57+
export default function Sitemap() {
58+
// This page is only used to generate the sitemap.xml
59+
return null;
60+
}

0 commit comments

Comments
 (0)