Skip to content

Commit 8e29435

Browse files
authored
Merge pull request #2 from acmucsd/website
barebones website
2 parents 5542d48 + 230b8cf commit 8e29435

26 files changed

+5718
-0
lines changed

website/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

website/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel
35+
36+
# persistence to get around not being able to pass data directly from getStaticPaths to getStaticProps
37+
.serde/*
38+
!.serde/README.md

website/.serde/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory serves as a "staging area" for Next.js's `getStaticPaths` data such that it can be read in `getStaticProps`. As the data is generated, the contents of this folder are untracked.

website/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
```
12+
13+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14+
15+
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
16+
17+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
18+
19+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20+
21+
## Learn More
22+
23+
To learn more about Next.js, take a look at the following resources:
24+
25+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27+
28+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29+
30+
## Deploy on Vercel
31+
32+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33+
34+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

website/lib/getWorkshops.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import glob from 'glob';
4+
import { promisify } from 'util';
5+
6+
const workshopsDirectory = path.join(process.cwd(), '..');
7+
8+
const slugify = (filepathArray: string | string[]) => {
9+
if (!Array.isArray(filepathArray)) {
10+
filepathArray = filepathArray.split('/')
11+
}
12+
return filepathArray.map((filepath) => filepath.toLowerCase().replace(/.ipynb$/, '').replace(/[^\w /]+/g, '').replace(/ +/g, '-'));
13+
}
14+
15+
export const getWorkshopPaths = async () => {
16+
const workshopPaths = await promisify(glob)(`**/*.ipynb`, { cwd: workshopsDirectory })
17+
return workshopPaths;
18+
}
19+
20+
export const getWorkshopByPath = async (filepath: string) => {
21+
const fullPath = path.join(workshopsDirectory, filepath);
22+
const fileContents = await promisify(fs.readFile)(fullPath, 'utf8');
23+
return fileContents;
24+
}
25+
26+
export const getAllWorkshops = async () => {
27+
const filepaths = await getWorkshopPaths();
28+
const workshops = await Promise.all(filepaths.map(async (filepath) => ({
29+
slug: slugify(filepath),
30+
content: await getWorkshopByPath(filepath),
31+
})));
32+
return workshops;
33+
}

0 commit comments

Comments
 (0)