From eacb858faa0a797b03a83c1d2e9f9c49c1285c0d Mon Sep 17 00:00:00 2001 From: Aditya Thakral Date: Mon, 8 Aug 2022 01:05:20 -0700 Subject: [PATCH] Fix comments --- public/api/schema/members.json | 2 +- scripts/change-dates.ts | 65 ---------------------------------- 2 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 scripts/change-dates.ts diff --git a/public/api/schema/members.json b/public/api/schema/members.json index 5d003f70..df8c6144 100644 --- a/public/api/schema/members.json +++ b/public/api/schema/members.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Member list", - "description": "List of all members of the Computer Science Club of the University of Waterloo", + "description": "List of all current members of the Computer Science Club of the University of Waterloo", "type": "object", "properties": { "members": { diff --git a/scripts/change-dates.ts b/scripts/change-dates.ts deleted file mode 100644 index 98a91782..00000000 --- a/scripts/change-dates.ts +++ /dev/null @@ -1,65 +0,0 @@ -import fs from "fs/promises"; -import path from "path"; - -import { format } from "date-fns"; - -import { - getEventsByTerm, - getEventTermsByYear, - getEventYears, -} from "@/lib/events"; -import { - getNewsByTerm, - getNewsTermsByYear, - getNewsYears, - NEWS_PATH, -} from "@/lib/news"; -import { DATE_FORMAT } from "@/utils"; - -/* -Note: -This script will not work for events by default anymore, since events now have startDate instead of endDate -*/ -const EVENTS_PATH = path.join("content", "events"); - -export async function main() { - for (const year of await getEventYears()) { - for (const term of await getEventTermsByYear(year)) { - for (const slug of await getEventsByTerm(year, term)) { - const filePath = path.join( - EVENTS_PATH, - year.toString(), - term, - `${slug}.md` - ); - const file = await fs.readFile(filePath, "utf-8"); - - await fs.writeFile(filePath, replaceDate(file)); - } - } - } - - for (const year of await getNewsYears()) { - for (const term of await getNewsTermsByYear(year)) { - for (const slug of await getNewsByTerm(year, term)) { - const filePath = path.join(NEWS_PATH, year, term, `${slug}.md`); - const file = await fs.readFile(filePath, "utf-8"); - - await fs.writeFile(filePath, replaceDate(file)); - } - } - } -} - -function replaceDate(file: string) { - const lines = file.split("\n"); - const dateLineIdx = lines.findIndex((line) => line.startsWith("date: ")); - const dateLine = lines[dateLineIdx]; - const date = new Date(dateLine.slice("date: ".length + 1, -1)); - - lines[dateLineIdx] = `date: '${format(date, DATE_FORMAT)}'`; - - return lines.join("\n"); -} - -void main();