Skip to content

Commit db9ea63

Browse files
committed
Add what's new page
1 parent 51ecbd5 commit db9ea63

File tree

3 files changed

+88
-7
lines changed

3 files changed

+88
-7
lines changed

common/src/constants.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
export const MIN_INT = Number.MIN_SAFE_INTEGER
22
export const MAX_INT = Number.MAX_SAFE_INTEGER
33

4-
export const supportEmail = '[email protected]';
5-
// export const marketingEmail = '[email protected]';
4+
export const supportEmail = '[email protected]'
5+
// export const marketingEmail = '[email protected]'
66

7-
export const githubRepo = "https://github.com/CompassConnections/Compass";
7+
export const githubRepoSlug = "CompassConnections/Compass"
8+
export const githubRepo = `https://github.com/${githubRepoSlug}`
89
export const githubIssues = `${githubRepo}/issues`
910

1011
export const paypalLink = "https://www.paypal.com/paypalme/CompassConnections"
@@ -16,9 +17,9 @@ export const redditLink = "https://www.reddit.com/r/CompassConnect"
1617
export const xLink = "https://x.com/compassmeet"
1718
export const formLink = "https://forms.gle/tKnXUMAbEreMK6FC6"
1819

19-
export const pStyle = "mt-1 text-gray-800 dark:text-white whitespace-pre-line";
20+
export const pStyle = "mt-1 text-gray-800 dark:text-white whitespace-pre-line"
2021

21-
export const IS_MAINTENANCE = false; // set to true to enable maintenance mode banner
22+
export const IS_MAINTENANCE = false // set to true to enable the maintenance mode banner
2223

23-
export const MIN_BIO_LENGTH = 250;
24+
export const MIN_BIO_LENGTH = 250
2425

web/components/page-base.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {HomeIcon, QuestionMarkCircleIcon} from '@heroicons/react/outline'
1+
import {HomeIcon, NewspaperIcon, QuestionMarkCircleIcon} from '@heroicons/react/outline'
22
import {
33
GlobeAltIcon,
44
HomeIcon as SolidHomeIcon,
@@ -117,11 +117,13 @@ const Social = {name: 'Social', href: '/social', icon: LinkIcon};
117117
const Organization = {name: 'Organization', href: '/organization', icon: GlobeAltIcon};
118118
const Vote = {name: 'Vote', href: '/vote', icon: MdThumbUp};
119119
const Contact = {name: 'Contact', href: '/contact', icon: FaEnvelope};
120+
const News = {name: "What's new", href: '/news', icon: NewspaperIcon};
120121

121122
const base = [
122123
About,
123124
faq,
124125
Vote,
126+
News,
125127
Social,
126128
Organization,
127129
Contact,

web/pages/news.tsx

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import React, {useEffect, useState} from "react"
2+
import axios from "axios"
3+
import ReactMarkdown from "react-markdown"
4+
import {PageBase} from "web/components/page-base"
5+
import {SEO} from "web/components/SEO"
6+
import {Col} from "web/components/layout/col"
7+
import {Title} from "web/components/widgets/title"
8+
import Link from "next/link"
9+
import {CompassLoadingIndicator} from "web/components/widgets/loading-indicator"
10+
import {githubRepoSlug} from "common/constants";
11+
12+
type Release = {
13+
id: number
14+
name: string
15+
tag_name: string
16+
body: string
17+
published_at: string
18+
html_url: string
19+
}
20+
21+
export default function WhatsNew() {
22+
const [releases, setReleases] = useState([])
23+
const [loading, setLoading] = useState(true)
24+
const [error, setError] = useState<string | null>(null)
25+
26+
useEffect(() => {
27+
async function fetchReleases() {
28+
try {
29+
const response = await axios.get(
30+
`https://api.github.com/repos/${githubRepoSlug}/releases`,
31+
{
32+
headers: {
33+
// Optional: if hitting rate limits, use a GitHub token
34+
// Authorization: `token ${process.env.REACT_APP_GITHUB_TOKEN}`
35+
},
36+
}
37+
)
38+
setReleases(response.data)
39+
} catch (err) {
40+
setError("Failed to fetch releases")
41+
} finally {
42+
setLoading(false)
43+
}
44+
}
45+
46+
fetchReleases()
47+
}, [])
48+
49+
return (
50+
<PageBase trackPageView={'news'} className={'mx-4'}>
51+
<SEO
52+
title={"What's new"}
53+
description={'All news and code updates'}
54+
url={`/news`}
55+
/>
56+
<Title className="text-3xl">What's New</Title>
57+
{loading ? <CompassLoadingIndicator/> :
58+
error ? <p>{error}</p> :
59+
<Col className="max-w-3xl mx-auto py-10 px-4 custom-link">
60+
{releases.map((release: Release) => (
61+
<div key={release.id} className="mb-10 border-b pb-6">
62+
<div className="flex justify-between items-center">
63+
<h2 className="text-xl font-semibold">{release.name || release.tag_name}</h2>
64+
<span className="text-sm text-gray-500">
65+
{new Date(release.published_at).toLocaleDateString()}
66+
</span>
67+
</div>
68+
<div className="mt-4 prose text-ink-1000">
69+
<ReactMarkdown>{release.body || "_No release notes provided._"}</ReactMarkdown>
70+
</div>
71+
<Link href={release.html_url}>View on GitHub</Link>
72+
</div>
73+
))}
74+
</Col>
75+
}
76+
</PageBase>
77+
)
78+
}

0 commit comments

Comments
 (0)