Skip to content

Commit 1b97198

Browse files
committed
chore: update URLs and metadata for dStruct domain transition
- Changed all instances of the domain from `dstruct.app` to `dstruct.pro` in the README, sitemap, and meta tags. - Updated the canonical link in the index page and added a canonical URL in the playground page for SEO optimization. - Enhanced the sitemap generation to reflect the new domain and included last modified dates for better indexing. - Adjusted the web manifest to include the correct app name and short name.
1 parent e8f2114 commit 1b97198

7 files changed

Lines changed: 84 additions & 22 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# dStruct - LeetCode Problem Visualization Web App
22

3-
#### [dstruct.app](https://dstruct.app/)
3+
#### [dstruct.pro](https://dstruct.pro/)
44

55
<p align="center">
6-
<a href="https://dstruct.app">
6+
<a href="https://dstruct.pro">
77
<img src="https://therealsujitk-vercel-badge.vercel.app/?app=dstruct&style=for-the-badge" alt="Deployed on Vercel" />
88
</a>
99
<a href="/LICENSE">
@@ -17,7 +17,7 @@ dStruct is a web app designed to assist users in understanding and visualizing L
1717
code editor where users can write and visualize their solutions.
1818

1919
<p align="center">
20-
<a href="https://dstruct.app/playground">
20+
<a href="https://dstruct.pro/playground">
2121
<img src="https://i.imgur.com/Q1FRwaK.png" alt="dStruct Web App" />
2222
</a>
2323
</p>

public/robots.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
User-agent: *
22
Allow: /
3+
Disallow: /api/
34

4-
Sitemap: https://dstruct.app/sitemap.xml
5+
Sitemap: https://dstruct.pro/sitemap.xml

public/site.webmanifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "",
3-
"short_name": "",
2+
"name": "dStruct",
3+
"short_name": "dStruct",
44
"icons": [
55
{
66
"src": "/android-chrome-192x192.png",

src/pages/_document.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,36 @@ function Document({ emotionStyleTags }: MyDocumentProps) {
2525
content="dStruct is a web app that helps you understand LeetCode problems. It allows you to visualize your solutions that you write in a built-in code editor."
2626
/>
2727

28+
<meta property="og:site_name" content="dStruct" />
2829
<meta property="og:title" content="dStruct" />
2930
<meta property="og:type" content="website" />
30-
<meta property="og:url" content="https://dstruct.app/" />
31+
<meta property="og:url" content="https://dstruct.pro/" />
3132
<meta
3233
property="og:description"
3334
content="dStruct is a web app that helps you understand LeetCode problems. It allows you to visualize your solutions that you write in a built-in code editor."
3435
/>
3536
<meta
3637
property="og:image"
37-
content="https://dstruct.app/static/screen2.png"
38+
content="https://dstruct.pro/static/screen2.png"
39+
/>
40+
<meta property="og:image:width" content="1200" />
41+
<meta property="og:image:height" content="630" />
42+
<meta
43+
property="og:image:alt"
44+
content="dStruct - LeetCode solution visualizer"
3845
/>
3946

4047
<meta name="twitter:card" content="summary_large_image" />
41-
<meta property="twitter:domain" content="dstruct.app" />
42-
<meta property="twitter:url" content="https://dstruct.app/" />
48+
<meta property="twitter:domain" content="dstruct.pro" />
49+
<meta property="twitter:url" content="https://dstruct.pro/" />
4350
<meta name="twitter:title" content="dStruct" />
4451
<meta
4552
name="twitter:description"
4653
content="dStruct is a web app that helps you understand LeetCode problems. It allows you to visualize your solutions that you write in a built-in code editor."
4754
/>
4855
<meta
4956
name="twitter:image"
50-
content="https://dstruct.app/static/screen2.png"
57+
content="https://dstruct.pro/static/screen2.png"
5158
/>
5259

5360
<link

src/pages/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const DashboardPage: NextPage<{
9494
<MainLayout onScroll={handleScroll} headerPosition="fixed">
9595
<Head>
9696
<title>dStruct</title>
97+
<link rel="canonical" href="https://dstruct.pro/" />
9798
</Head>
9899
{/* Hero Section */}
99100
<Box

src/pages/playground/[[...slug]].tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { darken, useTheme } from "@mui/material";
22
import type { GetServerSideProps, NextPage } from "next";
3+
import Head from "next/head";
34
import React from "react";
45

56
import { ConfigContext } from "#/context";
@@ -10,6 +11,7 @@ import { PlaygroundViewProvider } from "#/features/playground/context/Playground
1011
import { MobilePlayground } from "#/features/playground/ui/MobilePlayground";
1112
import { ProjectPanel } from "#/features/project/ui/ProjectPanel";
1213
import { TreeViewPanel } from "#/features/treeViewer/ui/TreeViewPanel";
14+
import { db } from "#/server/db/client";
1315
import { useAppConfig, useHasMounted } from "#/shared/hooks";
1416
import { useMobileLayout } from "#/shared/hooks/useMobileLayout";
1517
import {
@@ -47,18 +49,29 @@ const DesktopWrapper: React.FC<DesktopWrapperProps> = ({
4749
);
4850
};
4951

52+
const BASE_URL = "https://dstruct.pro";
53+
5054
type PlaygroundPageProps = {
5155
ssrDeviceType: SsrDeviceType;
56+
canonicalUrl: string;
57+
pageTitle: string;
5258
};
5359

54-
const PlaygroundPage: NextPage<PlaygroundPageProps> = () => {
60+
const PlaygroundPage: NextPage<PlaygroundPageProps> = ({
61+
canonicalUrl,
62+
pageTitle,
63+
}) => {
5564
const theme = useTheme();
5665
const isMobile = useMobileLayout();
5766

5867
const { data = {} } = useAppConfig();
5968

6069
return (
6170
<ConfigContext.Provider value={data}>
71+
<Head>
72+
<title>{pageTitle}</title>
73+
<link rel="canonical" href={canonicalUrl} />
74+
</Head>
6275
<PageScrollContainer
6376
isPage={true}
6477
options={
@@ -94,13 +107,30 @@ const PlaygroundPage: NextPage<PlaygroundPageProps> = () => {
94107

95108
export const getServerSideProps: GetServerSideProps<
96109
PlaygroundPageProps
97-
> = async ({ req, res }) => {
110+
> = async ({ req, res, params }) => {
98111
const ssrDeviceType = resolveSsrDeviceType(req.headers);
99112
setDeviceHintResponseHeaders(res);
100113

114+
const slug = params?.slug;
115+
const slugStr = Array.isArray(slug) ? slug[0] : undefined;
116+
const canonicalUrl = slugStr
117+
? `${BASE_URL}/playground/${slugStr}`
118+
: `${BASE_URL}/playground`;
119+
120+
let pageTitle = "Playground | dStruct";
121+
if (slugStr) {
122+
const project = await db.playgroundProject.findUnique({
123+
where: { slug: slugStr },
124+
select: { title: true },
125+
});
126+
pageTitle = project ? `${project.title} | dStruct` : "Playground | dStruct";
127+
}
128+
101129
return {
102130
props: {
103131
ssrDeviceType,
132+
canonicalUrl,
133+
pageTitle,
104134
},
105135
};
106136
};

src/pages/sitemap.xml.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,45 @@
11
import type { GetServerSideProps } from "next";
22

33
import { db } from "#/server/db/client";
4-
import type { PlaygroundProject } from "#/server/db/generated/client";
54

6-
function generateSiteMap(projects: Partial<PlaygroundProject>[]) {
5+
const BASE_URL = "https://dstruct.pro";
6+
7+
type ProjectForSitemap = {
8+
slug: string;
9+
updatedAt: string;
10+
};
11+
12+
function formatLastmod(date: Date | string): string {
13+
const d = typeof date === "string" ? new Date(date) : date;
14+
return d.toISOString().split("T")[0] ?? "";
15+
}
16+
17+
function generateSiteMap(projects: ProjectForSitemap[]) {
18+
const now = formatLastmod(new Date());
719
return `<?xml version="1.0" encoding="UTF-8"?>
820
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
9-
<!--We manually set the two URLs we know already-->
1021
<url>
11-
<loc>https://dstruct.app</loc>
22+
<loc>${BASE_URL}</loc>
23+
<lastmod>${now}</lastmod>
24+
<changefreq>weekly</changefreq>
25+
<priority>1.0</priority>
1226
</url>
1327
<url>
14-
<loc>https://dstruct.app/playground</loc>
28+
<loc>${BASE_URL}/playground</loc>
29+
<lastmod>${now}</lastmod>
30+
<changefreq>weekly</changefreq>
31+
<priority>0.9</priority>
1532
</url>
1633
${projects
17-
.map(({ slug }) => {
34+
.map(({ slug, updatedAt }) => {
35+
const lastmod = formatLastmod(updatedAt);
1836
return `
19-
<url>
20-
<loc>${`https://dstruct.app/playground/${slug}`}</loc>
21-
</url>
37+
<url>
38+
<loc>${BASE_URL}/playground/${slug}</loc>
39+
<lastmod>${lastmod}</lastmod>
40+
<changefreq>weekly</changefreq>
41+
<priority>0.8</priority>
42+
</url>
2243
`;
2344
})
2445
.join("")}
@@ -33,8 +54,10 @@ function SiteMap() {
3354
export const getServerSideProps: GetServerSideProps = async ({ res }) => {
3455
// We make an API call to gather the URLs for our site
3556
const projects = await db.playgroundProject.findMany({
57+
where: { isPublic: true },
3658
select: {
3759
slug: true,
60+
updatedAt: true,
3861
},
3962
});
4063

0 commit comments

Comments
 (0)