Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/cf-pages-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22.x
Expand Down
4 changes: 4 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// @ts-check
import { defineConfig } from 'astro/config';
import { remarkModifiedTime } from './remark-modified-time.mjs';

import mdx from '@astrojs/mdx';

import tailwindcss from '@tailwindcss/vite';

// https://astro.build/config
export default defineConfig({
markdown: {
remarkPlugins: [remarkModifiedTime]
},
outDir: './build',
integrations: [mdx()],
vite: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@astrojs/mdx": "^4.3.13",
"@tailwindcss/vite": "^4.1.18",
"astro": "^5.16.8",
"dayjs": "^1.11.19",
"tailwindcss": "^4.1.18"
}
}
9 changes: 9 additions & 0 deletions remark-modified-time.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { execSync } from "child_process";

export function remarkModifiedTime() {
return function (tree, file) {
const filepath = file.history[0];
const result = execSync(`git log -1 --pretty="format:%cI" "${filepath}"`);
file.data.astro.frontmatter.lastModified = result.toString();
};
}
19 changes: 19 additions & 0 deletions src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
---
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";
import "../styles/global.css";
import Sidebar from "../components/Sidebar.astro";
import ThemeToggle from "../components/ThemeToggle.astro";

dayjs.extend(utc)
dayjs.extend(timezone)

interface Props {
title: string;
description?: string;
pageDescription?: string;
showTitle?: boolean;
lastModified?: string;
}

const {
title,
description = "UIUC CS Wiki - A student-maintained guide to CS courses and resources",
pageDescription,
showTitle = false,
lastModified,
} = Astro.props;

const parsedDate = lastModified ? dayjs(lastModified) : null;
const formattedDate = parsedDate?.isValid()
? parsedDate.tz("America/Chicago").format("MMMM DD, YYYY")
: "Unknown";
---

<!doctype html>
Expand Down Expand Up @@ -89,6 +102,12 @@ const {
)
}
<slot />

{parsedDate && (
<p class="mt-12 pt-4 border-t border-wiki-border text-sm text-wiki-muted">
Last updated: {formattedDate}
</p>
)}
</div>
</main>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/classes/[subject]/[course].astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export async function getStaticPaths() {
}

const { entry } = Astro.props;
const { Content } = await entry.render();
const { Content, remarkPluginFrontmatter } = await entry.render();
const course = entry.data;
---

<BaseLayout title={`${course.subject} ${course.number} ${course.section}`}>
<BaseLayout title={`${course.subject} ${course.number} ${course.section}`} lastModified={remarkPluginFrontmatter.lastModified}>
<nav class="mb-6 flex items-center gap-2 text-sm text-wiki-muted [&_a]:no-underline">
<a href="/" class="hover:text-wiki-link">Home</a>
<span>/</span>
Expand Down
5 changes: 3 additions & 2 deletions src/pages/guides/[slug].astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
import dayjs from "dayjs"
import BaseLayout from "../../layouts/BaseLayout.astro";
import { getCollection } from "astro:content";

Expand All @@ -12,10 +13,10 @@ export async function getStaticPaths() {
}

const { guide } = Astro.props;
const { Content } = await guide.render();
const { Content, remarkPluginFrontmatter } = await guide.render();
---

<BaseLayout title={guide.data.title}>
<BaseLayout title={guide.data.title} lastModified={remarkPluginFrontmatter.lastModified}>
<nav class="mb-6 flex items-center gap-2 text-sm text-wiki-muted [&_a]:no-underline">
<a href="/" class="hover:text-wiki-link">Home</a>
<span>/</span>
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,11 @@ csso@^5.0.5:
dependencies:
css-tree "~2.2.0"

dayjs@^1.11.19:
version "1.11.19"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.19.tgz#15dc98e854bb43917f12021806af897c58ae2938"
integrity sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==

debug@^4.0.0, debug@^4.4.0, debug@^4.4.3:
version "4.4.3"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a"
Expand Down
Loading