yjernite HF Staff commited on
Commit
63c2f57
·
verified ·
1 Parent(s): 68c76e8

Upload 3 files

Browse files
Files changed (2) hide show
  1. js/pages/AreaPage.js +44 -7
  2. js/pages/HomePage.js +1 -1
js/pages/AreaPage.js CHANGED
@@ -150,13 +150,50 @@ export function renderAreaPage(areaId) {
150
  init: () => {
151
  // Initialize artifact carousels for each sub-area with a small delay
152
  // to ensure DOM elements are fully rendered
153
- setTimeout(() => {
154
- subAreas.forEach(subArea => {
155
- // For now, show all artifacts in each carousel
156
- // Later this will be filtered by the backend
157
- const carouselId = `${subArea.id}-artifacts-carousel`;
158
- createArtifactCarousel(featuredArtifacts, carouselId);
159
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  }, 50);
161
 
162
  // Initialize resource cards
 
150
  init: () => {
151
  // Initialize artifact carousels for each sub-area with a small delay
152
  // to ensure DOM elements are fully rendered
153
+ setTimeout(async () => {
154
+ try {
155
+ console.log('Loading artifacts from JSON...');
156
+ // Load artifacts from JSON file
157
+ const response = await fetch('/data/artifacts.json');
158
+ if (!response.ok) {
159
+ throw new Error(`HTTP error! status: ${response.status}`);
160
+ }
161
+ const allArtifacts = await response.json();
162
+ console.log('Artifacts loaded:', allArtifacts.length, 'items');
163
+
164
+ subAreas.forEach(subArea => {
165
+ try {
166
+ // Filter artifacts by topics (subAreaTags in JSON)
167
+ const filteredArtifacts = allArtifacts.filter(artifact =>
168
+ artifact.topics && artifact.topics.includes(subArea.id)
169
+ );
170
+
171
+ // Transform field names to match expected format
172
+ const transformedArtifacts = filteredArtifacts.map(artifact => ({
173
+ ...artifact,
174
+ areaTags: artifact.areas,
175
+ subAreaTags: artifact.topics,
176
+ sourceUrl: artifact.url
177
+ }));
178
+
179
+ console.log(`Filtered artifacts for ${subArea.id}:`, transformedArtifacts.length);
180
+ const carouselId = `${subArea.id}-artifacts-carousel`;
181
+ createArtifactCarousel(transformedArtifacts, carouselId);
182
+ } catch (error) {
183
+ console.error(`Error creating carousel for ${subArea.id}:`, error);
184
+ // Fallback to featured artifacts if filtering fails
185
+ const carouselId = `${subArea.id}-artifacts-carousel`;
186
+ createArtifactCarousel(featuredArtifacts, carouselId);
187
+ }
188
+ });
189
+ } catch (error) {
190
+ console.error('Error loading artifacts from JSON:', error);
191
+ // Fallback to featured artifacts for all carousels
192
+ subAreas.forEach(subArea => {
193
+ const carouselId = `${subArea.id}-artifacts-carousel`;
194
+ createArtifactCarousel(featuredArtifacts, carouselId);
195
+ });
196
+ }
197
  }, 50);
198
 
199
  // Initialize resource cards
js/pages/HomePage.js CHANGED
@@ -148,7 +148,7 @@ function getAreaShortDescription(areaId) {
148
  efficiency: 'Costs, energy, sustainability',
149
  personal: 'Personal interactions, agency',
150
  rights: 'Legal frameworks, compliance',
151
- ecosystems: 'Markets, labor, power dynamics'
152
  };
153
  return descriptions[areaId] || '';
154
  }
 
148
  efficiency: 'Costs, energy, sustainability',
149
  personal: 'Personal interactions, agency',
150
  rights: 'Legal frameworks, compliance',
151
+ ecosystems: 'Markets, labor, and adoption dynamics'
152
  };
153
  return descriptions[areaId] || '';
154
  }