136 <div className="rounded-lg overflow-hidden shadow-lg">
137 <img
138 src={story.imageUrl}
139 alt={`Illustration for ${story.title}`}
140 className="w-full h-auto"
12 font-family: 'Comic Neue', cursive;
13 background-color: #f0f9ff;
14 background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%239C92AC' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
15 }
16
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { saveStory, getAllStories, getStoryById, deleteStory } from "../database/queries.ts";
3import { generateStory, generateImagePrompt } from "../services/storyGenerator.ts";
4import { StoryOptions, Story } from "../../shared/types.ts";
5
14 const { title, content, animalName } = await generateStory(options);
15
16 // Generate image prompt
17 const imagePrompt = generateImagePrompt(options, animalName, title);
18
19 // Create image URL using Val Town's AI image generation
20 const imageUrl = `https://maxm-imggenurl.web.val.run/${encodeURIComponent(imagePrompt)}`;
21
22 // Create the story object
32 style: options.style,
33 styleEmoji: options.styleEmoji,
34 imageUrl,
35 createdAt: new Date().toISOString()
36 };
55}
56
57export function generateImagePrompt(options: StoryOptions, animalName: string, title: string): string {
58 const { animal, color, activity, style } = options;
59
9 title, content, animal, animal_emoji, animal_name,
10 color, activity, activity_emoji, style, style_emoji,
11 image_url, created_at
12 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
13 RETURNING id`,
23 story.style,
24 story.styleEmoji,
25 story.imageUrl,
26 story.createdAt,
27 ]
38 animal_name as animalName, color, activity,
39 activity_emoji as activityEmoji, style, style_emoji as styleEmoji,
40 image_url as imageUrl, created_at as createdAt
41 FROM ${STORIES_TABLE}
42 ORDER BY created_at DESC
53 animal_name as animalName, color, activity,
54 activity_emoji as activityEmoji, style, style_emoji as styleEmoji,
55 image_url as imageUrl, created_at as createdAt
56 FROM ${STORIES_TABLE}
57 WHERE id = ?`,
19 style TEXT NOT NULL,
20 style_emoji TEXT NOT NULL,
21 image_url TEXT NOT NULL,
22 created_at TEXT NOT NULL
23 )
13 style: string;
14 styleEmoji: string;
15 imageUrl: string;
16 createdAt: string;
17}
244 postEl.innerHTML = `
245 <a href="/blog/${post.id}" class="block">
246 <img src="${post.image}" alt="${post.title}" class="w-full h-48 object-cover">
247 <div class="p-6">
248 <h3 class="text-xl font-semibold mb-2">${post.title}</h3>
53 </div>
54 </div>
55 <div class="absolute inset-0 bg-cover bg-center opacity-20" style="background-image: url('https://maxm-imggenurl.web.val.run/aerial-view-of-arctic-sea-ice-with-cracks-and-leads-scientific-photography')"></div>
56 </section>
57
473 projectEl.className = 'overflow-hidden rounded-lg shadow transition-transform hover:scale-105';
474
475 // Use placeholder image if project image is not available
476 const imageUrl = project.image || 'https://maxm-imggenurl.web.val.run/sea-ice-research-' + project.id;
477
478 projectEl.innerHTML = `
479 <a href="/research/${project.id}" class="block">
480 <div class="h-48 bg-cover bg-center" style="background-image: url('${imageUrl}')"></div>
481 <div class="bg-white p-6">
482 <h3 class="text-xl font-semibold mb-3">${project.title}</h3>
510 memberEl.className = 'overflow-hidden rounded-lg shadow transition-transform hover:scale-105';
511
512 // Use placeholder image if member image is not available
513 const imageUrl = member.image || 'https://maxm-imggenurl.web.val.run/portrait-of-scientist-' + member.id;
514
515 memberEl.innerHTML = `
516 <a href="/team/${member.id}" class="block">
517 <div class="h-64 bg-cover bg-center" style="background-image: url('${imageUrl}')"></div>
518 <div class="bg-white p-4">
519 <h3 class="text-lg font-semibold">${member.name}</h3>
585 });
586
587 // Use image if available
588 const imageHtml = item.image ?
589 `<div class="mb-4">
590 <img src="${item.image}" alt="${item.title}" class="w-full h-48 object-cover rounded">
591 </div>` : '';
592
593 newsEl.innerHTML = `
594 ${imageHtml}
595 <h3 class="text-xl font-semibold mb-2">${item.title}</h3>
596 <p class="text-gray-600 mb-4">${formattedDate}</p>
5In a production environment, this would include:
6
7- Images of team members
8- Research project images
9- Logos and icons
10- Other static media files
11
12For this demo, we're using AI-generated placeholder images via the URL pattern:
13`https://maxm-imggenurl.web.val.run/[description]`