This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
4,064 additions
and
1,435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,3 +130,4 @@ dist | |
.pnp.* | ||
|
||
out | ||
.contentlayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Enable rewrite engine | ||
RewriteEngine On | ||
|
||
# Check if the .html version of the requested resource exists | ||
RewriteCond %{REQUEST_FILENAME}.html -f | ||
# Rewrite to .html version if existing (for requests without an extension) | ||
RewriteRule ^([^\.]+)$ $1.html [NC,L] | ||
|
||
# Custom error document | ||
ErrorDocument 404 /404.html | ||
|
||
# Internally rewrite requests to 404.html, while maintaining the 404 status | ||
RewriteCond %{ENV:REDIRECT_STATUS} ^$ | ||
RewriteRule ^404\.html$ - [R=404,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { allPages } from 'contentlayer/generated' | ||
import { notFound } from 'next/navigation' | ||
import { useMDXComponent } from 'next-contentlayer/hooks' | ||
|
||
export async function generateStaticParams() { | ||
return allPages.map(page => ({ | ||
slug: page.slug, | ||
})).filter(slug => slug) | ||
} | ||
|
||
export default function Page({ params }: { params: { slug: string } }) { | ||
console.log(allPages) | ||
const page = allPages.find(page => page.slug === params.slug) | ||
if (!page) notFound() | ||
|
||
const MDXContent = useMDXComponent(page.body.code) | ||
|
||
return <div className="card"> | ||
<h1 className="text-3xl font-bold mb-2">{page.title}</h1> | ||
<div className="prose"> | ||
<MDXContent /> | ||
</div> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default function NotFound() { | ||
return <div> | ||
<p><strong>404</strong>: The page you requested couldn't be found.</p> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import Page from "./[slug]/page"; | ||
|
||
export default function Home() { | ||
return <div>Hello, world!</div> | ||
} | ||
return <Page params={{ slug: "" }} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: Home | ||
--- | ||
|
||
Hello, world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: Syllabus | ||
--- | ||
|
||
Blah blah this is a syllabus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { defineDocumentType, makeSource } from 'contentlayer/source-files' | ||
|
||
export const Page = defineDocumentType(() => ({ | ||
name: 'Page', | ||
filePathPattern: `pages/**/*.mdx`, | ||
contentType: 'mdx', | ||
fields: { | ||
title: { type: 'string', required: true }, | ||
}, | ||
computedFields: { | ||
slug: { | ||
type: 'string', | ||
resolve: page => { | ||
const path = page._raw.flattenedPath | ||
if (path === 'pages/index') return '/' | ||
return path.slice("pages/".length) | ||
}, | ||
}, | ||
}, | ||
})) | ||
|
||
export const Homework = defineDocumentType(() => ({ | ||
name: 'Homework', | ||
filePathPattern: `homework/**/*.mdx`, | ||
contentType: 'mdx', | ||
fields: { | ||
title: { type: 'string', required: true }, | ||
}, | ||
computedFields: { | ||
slug: { type: 'string', resolve: page => page._raw.flattenedPath.slice("homework/".length) }, | ||
}, | ||
})) | ||
|
||
export const Lecture = defineDocumentType(() => ({ | ||
name: 'Lecture', | ||
filePathPattern: `lectures/**/*.mdx`, | ||
contentType: 'mdx', | ||
fields: { | ||
title: { type: 'string', required: true }, | ||
}, | ||
computedFields: { | ||
slug: { type: 'string', resolve: page => page._raw.flattenedPath.slice("lectures/".length) }, | ||
}, | ||
})) | ||
|
||
export const Exam = defineDocumentType(() => ({ | ||
name: 'Exam', | ||
filePathPattern: `exams/**/*.mdx`, | ||
contentType: 'mdx', | ||
fields: { | ||
title: { type: 'string', required: true }, | ||
}, | ||
computedFields: { | ||
slug: { type: 'string', resolve: page => page._raw.flattenedPath.slice("exams/".length) }, | ||
}, | ||
})) | ||
|
||
export default makeSource({ | ||
contentDirPath: 'content', | ||
documentTypes: [Page, Homework, Lecture, Exam], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
const { withContentlayer } = require('next-contentlayer') | ||
|
||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
basePath: "/~cis1951", | ||
output: "export", | ||
pageExtensions: ["js", "jsx", "ts", "tsx", "mdx"], | ||
} | ||
|
||
module.exports = nextConfig | ||
module.exports = withContentlayer(nextConfig) |
Oops, something went wrong.