Align header, footer, brand, homepage course preview, faculty links, and the course catalog with the documented changes. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
import { readFileSync, existsSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import pg from "pg";
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const envPath = path.join(root, ".env.local");
|
|
if (existsSync(envPath)) {
|
|
for (const line of readFileSync(envPath, "utf8").split(/\r?\n/)) {
|
|
const m = line.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*)\s*$/);
|
|
if (m && !(m[1] in process.env)) process.env[m[1]] = m[2];
|
|
}
|
|
}
|
|
|
|
const client = new pg.Client({ connectionString: process.env.DATABASE_URL });
|
|
await client.connect();
|
|
const cats = await client.query(
|
|
"select slug, label, show_in_filter, published from course_categories order by sort_order",
|
|
);
|
|
const tags = await client.query(
|
|
"select slug, label, show_in_nav, show_in_filter, published from course_tags order by sort_order",
|
|
);
|
|
const links = await client.query(`
|
|
select c.slug as course,
|
|
coalesce(json_agg(distinct cat.slug) filter (where cat.slug is not null), '[]') as cats,
|
|
coalesce(json_agg(distinct t.slug) filter (where t.slug is not null), '[]') as tags
|
|
from courses c
|
|
left join course_category_links cl on cl.course_id = c.id
|
|
left join course_categories cat on cat.id = cl.category_id
|
|
left join course_tag_links tl on tl.course_id = c.id
|
|
left join course_tags t on t.id = tl.tag_id
|
|
where c.published
|
|
group by c.slug
|
|
order by c.slug
|
|
`);
|
|
console.log("CATEGORIES", cats.rows);
|
|
console.log("TAGS", tags.rows);
|
|
console.log("COURSE LINKS", links.rows);
|
|
await client.end();
|