Accessibility fixes.

This commit is contained in:
Jennie Robinson Faber 2026-04-05 19:27:25 +01:00
parent 689548e389
commit dae983734a
7 changed files with 201 additions and 140 deletions

View file

@ -5,109 +5,128 @@
* Safe to run multiple times.
*/
import 'dotenv/config'
import mongoose from 'mongoose'
import Tag from '../server/models/tag.js'
import { connectDB } from '../server/utils/mongoose.js'
import "dotenv/config";
import mongoose from "mongoose";
import Tag from "../server/models/tag.js";
import { connectDB } from "../server/utils/mongoose.js";
// Convert a slug like "qa-and-testing" to "QA and Testing"
// Special-cases common abbreviations.
const ABBREVIATIONS = new Map([
['qa', 'QA'],
['ux', 'UX'],
['ui', 'UI'],
['devops', 'DevOps'],
])
["qa", "QA"],
["ux", "UX"],
["ui", "UI"],
["devops", "DevOps"],
]);
function slugToLabel(slug) {
return slug
.split('-')
.map((word) => ABBREVIATIONS.get(word) ?? word.charAt(0).toUpperCase() + word.slice(1))
.join(' ')
.split("-")
.map(
(word) =>
ABBREVIATIONS.get(word) ?? word.charAt(0).toUpperCase() + word.slice(1),
)
.join(" ");
}
const CRAFT_SLUGS = [
'game-design',
'programming',
'narrative-design',
'art-and-animation',
'audio-and-music',
'production-management',
'qa-and-testing',
'community-management',
'marketing-and-comms',
'ux-and-ui-design',
'business-development',
'devops-and-tools',
'localization',
'accessibility',
'analytics-and-data',
'education-and-mentoring',
]
"game-design",
"programming",
"narrative-design",
"art-and-animation",
"audio-and-music",
"production-management",
"qa-and-testing",
"community-management",
"marketing-and-comms",
"ux-and-ui-design",
"business-development",
"devops-and-tools",
"localization",
"accessibility",
"analytics-and-data",
"education-and-mentoring",
];
const COOPERATIVE_SLUGS = [
'governance',
'finance-and-budgeting',
'legal-structures',
'conflict-resolution',
'consensus-decision-making',
'revenue-sharing',
'cooperative-bylaws',
'member-onboarding',
'democratic-management',
'worker-ownership',
'platform-cooperativism',
'cooperative-marketing',
'shared-resources',
'cooperative-funding',
'community-building',
'equity-and-inclusion',
'cooperative-tech',
'sustainability',
'collective-bargaining',
'inter-coop-collaboration',
]
"governance",
"finance-and-budgeting",
"legal-structures",
"conflict-resolution",
"consensus-decision-making",
"revenue-sharing",
"cooperative-bylaws",
"member-onboarding",
"democratic-management",
"worker-ownership",
"platform-cooperativism",
"cooperative-marketing",
"shared-resources",
"cooperative-funding",
"community-building",
"equity-and-inclusion",
"cooperative-tech",
"sustainability",
"collective-bargaining",
"inter-coop-collaboration",
];
async function seedTags() {
await connectDB()
await connectDB();
const tagDefs = [
...CRAFT_SLUGS.map((slug) => ({ slug, pool: 'craft', label: slugToLabel(slug) })),
...COOPERATIVE_SLUGS.map((slug) => ({ slug, pool: 'cooperative', label: slugToLabel(slug) })),
]
...CRAFT_SLUGS.map((slug) => ({
slug,
pool: "craft",
label: slugToLabel(slug),
})),
...COOPERATIVE_SLUGS.map((slug) => ({
slug,
pool: "cooperative",
label: slugToLabel(slug),
})),
];
let upserted = 0
let unchanged = 0
let upserted = 0;
let unchanged = 0;
for (const { slug, pool, label } of tagDefs) {
const result = await Tag.updateOne(
{ slug },
{ $setOnInsert: { slug, pool, label, active: true, createdAt: new Date() } },
{ upsert: true }
)
{
$setOnInsert: {
slug,
pool,
label,
active: true,
createdAt: new Date(),
},
},
{ upsert: true },
);
if (result.upsertedCount > 0) {
console.log(` + Created [${pool}] ${label} (${slug})`)
upserted++
console.log(` + Created [${pool}] ${label} (${slug})`);
upserted++;
} else {
unchanged++
unchanged++;
}
}
console.log('\n=== Seed Complete ===')
console.log(` Total tags defined: ${tagDefs.length}`)
console.log(` Newly created: ${upserted}`)
console.log(` Already existed: ${unchanged}`)
console.log("\n=== Seed Complete ===");
console.log(` Total tags defined: ${tagDefs.length}`);
console.log(` Newly created: ${upserted}`);
console.log(` Already existed: ${unchanged}`);
}
seedTags()
.then(() => {
console.log('\nTag seed completed successfully')
process.exit(0)
console.log("\nTag seed completed successfully");
process.exit(0);
})
.catch((err) => {
console.error('\nTag seed failed:', err)
process.exit(1)
console.error("\nTag seed failed:", err);
process.exit(1);
})
.finally(() => {
mongoose.connection.close()
})
mongoose.connection.close();
});