// pages/ResourcesPage.js - Resources page functionality for SPA
import { homeBackgroundImage, areasData } from '../data/areas.js';
import { pressMentions } from '../data/press.js';
import { sampleResources } from '../data/resources.js';
import { createResourceCard, initializeResourceCards } from '../cards/ResourceCard.js';
export function renderResourcesPage() {
const content = `
Technical Resources
Our team develops technical artifacts in the course of their research and policy work.
These resources include datasets, tools, benchmarks, and interactive applications that
support transparency, reproducibility, and accessibility in AI research and governance.
${pressMentions.map((article, index) => {
// Get the primary area for this article
const primaryArea = areasData[article.areaTags[0]];
const primaryColor = primaryArea?.primaryColor || 'gray';
// Determine alignment (alternating)
const isLeftAligned = index % 2 === 0;
const alignment = isLeftAligned ? 'justify-start' : 'justify-end';
const borderSide = isLeftAligned ? 'border-l-2' : 'border-r-2';
const borderColor = `border-${primaryColor}-200`;
// Format date
const formattedDate = new Date(article.date).toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
// Generate area tags
const areaTagsHtml = article.areaTags.map(areaId => {
const area = areasData[areaId];
if (!area) return '';
return `${area.name}`;
}).join('');
// Generate sub-area tags
const subAreaTagsHtml = article.subAreaTags.map(subAreaKey => {
// Find the sub-area name and color by looking through all areas
let subAreaName = subAreaKey; // fallback to key if not found
let textColor = 'text-gray-700'; // fallback color
for (const areaKey in areasData) {
const area = areasData[areaKey];
if (area.subAreas && area.subAreas[subAreaKey]) {
const subArea = area.subAreas[subAreaKey];
subAreaName = typeof subArea === 'string' ? subArea : subArea.name;
// Extract just the text color from the sub-area color
if (typeof subArea === 'object' && subArea.color) {
const colorMatch = subArea.color.match(/text-(\w+)-(\d+)/);
if (colorMatch) {
textColor = `text-${colorMatch[1]}-700`; // Use consistent 700 shade
}
}
break;
}
}
return `${subAreaName}`;
}).join('');
return `