Skip to content

Commit acace22

Browse files
elliotBraemgagdiez
andauthored
Creates hackathon page, reading from awesome-near docs (#2986)
* creates hackathon page, reading awesome-near docs * Delete yarn.lock --------- Co-authored-by: Guille <gagdiez.c@gmail.com>
1 parent afb0088 commit acace22

3 files changed

Lines changed: 622 additions & 0 deletions

File tree

website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"react-monaco-editor": "^0.59.0",
6767
"react-syntax-highlighter": "^16",
6868
"react-toastify": "^11.0.5",
69+
"remark-gfm": "^4.0.1",
6970
"sass": "^1.89.2",
7071
"stream-browserify": "^3.0.0",
7172
"styled-components": "^6.1.19",

website/src/pages/hackathons.jsx

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
import Layout from '@theme/Layout';
2+
import { useState, useEffect } from 'react';
3+
import ReactMarkdown from 'react-markdown';
4+
import remarkGfm from 'remark-gfm';
5+
import Card from '@site/src/components/UI/Card';
6+
import Button from '@site/src/components/UI/Button';
7+
import styles from './hackathons.module.scss';
8+
9+
const AWESOME_NEAR_URL = 'https://raw.githubusercontent.com/near/awesome-near/master/README.md';
10+
11+
const fetcher = (url) => fetch(url).then((res) => res.text());
12+
13+
function processMarkdownLinks(markdown) {
14+
if (!markdown) return '';
15+
16+
let processed = markdown;
17+
18+
processed = processed.replace(
19+
/\[([^\]]+)\]\(https:\/\/docs\.near\.org\/([^)]+)\)/g,
20+
'[$1](/$2)'
21+
);
22+
23+
processed = processed.replace(
24+
/\[([^\]]+)\]\(https:\/\/docs\.near\.org\)/g,
25+
'[$1](/)'
26+
);
27+
28+
const footerIndex = processed.indexOf('*To add a tool');
29+
if (footerIndex > -1) {
30+
processed = processed.substring(0, footerIndex);
31+
}
32+
33+
return processed;
34+
}
35+
36+
const Hackathons = () => {
37+
const [awesomeNearContent, setAwesomeNearContent] = useState('');
38+
const [loading, setLoading] = useState(true);
39+
const [error, setError] = useState(null);
40+
41+
useEffect(() => {
42+
const fetchContent = async () => {
43+
try {
44+
const markdown = await fetcher(AWESOME_NEAR_URL);
45+
setAwesomeNearContent(markdown);
46+
setLoading(false);
47+
} catch (err) {
48+
console.error('Failed to fetch awesome-near:', err);
49+
setError('Failed to load Awesome NEAR content');
50+
setLoading(false);
51+
}
52+
};
53+
54+
fetchContent();
55+
}, []);
56+
57+
const processedContent = processMarkdownLinks(awesomeNearContent);
58+
59+
if (loading) {
60+
return (
61+
<Layout title="Building on NEAR" description="Helpful resource directory to get started">
62+
<div className={styles.loadingContainer}>
63+
<h1>Loading Resources...</h1>
64+
</div>
65+
</Layout>
66+
);
67+
}
68+
69+
return (
70+
<Layout title="Building on NEAR" description="Helpful resource directory to get started">
71+
<div className={styles.hackathonsPage}>
72+
<div className={styles.container}>
73+
<header className={styles.header}>
74+
<h1 className={styles.title}>Building on NEAR</h1>
75+
<p className={styles.subtitle}>
76+
Helpful resource directory to get started
77+
</p>
78+
</header>
79+
80+
<section className={styles.mainContent}>
81+
<h2>Getting Started</h2>
82+
83+
<div className={styles.topGrid}>
84+
<Card className={styles.topCard} variant="icon" icon={<span className={styles.emoji}>🌿</span>}>
85+
<h3>What is NEAR?</h3>
86+
<ul>
87+
<li><a href="/protocol/basics">NEAR Protocol Basics</a></li>
88+
<li><a href="https://docs.near.ai/" target="_blank" rel="noopener noreferrer">NEAR AI Documentation</a></li>
89+
<li><a href="https://docs.near-intents.org/near-intents" target="_blank" rel="noopener noreferrer">NEAR Intents</a></li>
90+
<li><a href="/tutorials/auction/introduction">Mastering NEAR Tutorial</a></li>
91+
</ul>
92+
</Card>
93+
94+
<Card className={styles.topCard} variant="icon" icon={<span className={styles.emoji}>💬</span>}>
95+
<h3>Developer Support</h3>
96+
<p>
97+
<a href="https://near.dev/telegram-chats" target="_blank" rel="noopener noreferrer">
98+
Join the Telegram Developer Chats
99+
</a>
100+
</p>
101+
</Card>
102+
103+
<Card className={styles.topCard} variant="icon" icon={<span className={styles.emoji}>🧑‍💻</span>}>
104+
<h3>Need NEAR AI Credits?</h3>
105+
<p>
106+
<a href="https://www.notion.so/Requesting-NEAR-AI-Cloud-Credits-2deda22d7b6481aea8e1e30282efcb5e" target="_blank" rel="noopener noreferrer">
107+
Request NEAR AI Cloud Credits
108+
</a>
109+
</p>
110+
</Card>
111+
</div>
112+
</section>
113+
114+
<section className={styles.awesomeNearSection}>
115+
<h2 className={styles.sectionTitle}>Awesome NEAR</h2>
116+
{error ? (
117+
<Card className={styles.errorCard}>
118+
<p>{error}</p>
119+
<Button href="https://github.com/near/awesome-near" target="_blank">
120+
View on GitHub
121+
</Button>
122+
</Card>
123+
) : (
124+
<>
125+
<div className={styles.awesomeNearContent}>
126+
<ReactMarkdown
127+
remarkPlugins={[remarkGfm]}
128+
components={{
129+
h1: ({ children }) => null,
130+
h2: ({ children }) => <h2 className={styles.mdH2}>{children}</h2>,
131+
h3: ({ children }) => <h3 className={styles.mdH3}>{children}</h3>,
132+
table: ({ children }) => <table className={styles.mdTable}>{children}</table>,
133+
thead: ({ children }) => <thead className={styles.mdThead}>{children}</thead>,
134+
tbody: ({ children }) => <tbody className={styles.mdTbody}>{children}</tbody>,
135+
tr: ({ children }) => <tr className={styles.mdTr}>{children}</tr>,
136+
td: ({ children }) => <td className={styles.mdTd}>{children}</td>,
137+
a: ({ href, children }) => {
138+
const isExternal = href && (href.startsWith('http://') || href.startsWith('https://'));
139+
return (
140+
<a
141+
href={href}
142+
target={isExternal ? '_blank' : undefined}
143+
rel={isExternal ? 'noopener noreferrer' : undefined}
144+
className={styles.mdLink}
145+
>
146+
{children}
147+
</a>
148+
);
149+
},
150+
ul: ({ children }) => <ul className={styles.mdUl}>{children}</ul>,
151+
li: ({ children }) => <li className={styles.mdLi}>{children}</li>,
152+
code: ({ children }) => <code className={styles.mdCode}>{children}</code>,
153+
hr: () => <hr className={styles.mdHr} />,
154+
p: ({ children }) => <p className={styles.mdP}>{children}</p>,
155+
}}
156+
>
157+
{processedContent}
158+
</ReactMarkdown>
159+
</div>
160+
<div className={styles.awesomeNearFooter}>
161+
<a href="https://github.com/near/awesome-near" target="_blank" rel="noopener noreferrer">
162+
View and contribute to Awesome NEAR on GitHub →
163+
</a>
164+
</div>
165+
</>
166+
)}
167+
</section>
168+
</div>
169+
</div>
170+
</Layout>
171+
);
172+
};
173+
174+
export default Hackathons;

0 commit comments

Comments
 (0)