Skip to content

Commit 73b1282

Browse files
committed
wip
1 parent 887935f commit 73b1282

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

pages/blog/iniciativas-2025.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ website: https://mariagrandury.com
1111
twitter: https://twitter.com/mariagrandury
1212
linkedin: https://www.linkedin.com/in/mariagrandury
1313
huggingface: https://huggingface.co/mariagrandury
14+
suggestedPosts:
15+
- /blog/include
1416
---
1517

1618
## 🔥 Hackathon SomosNLP 2025

src/components/BlogPost.vue

+70-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,65 @@
11
<script setup lang="ts">
2-
import { computed } from 'vue';
2+
import { computed, onMounted, ref, watch } from 'vue';
33
import { useHead } from '@vueuse/head'
44
import { useRoute } from 'vue-router';
55
66
import { useI18n } from 'vue-i18n';
77
const { d } = useI18n();
88
9+
interface SuggestedPost {
10+
path: string;
11+
title: string;
12+
cover?: string;
13+
description?: string;
14+
}
15+
916
const { frontmatter } = defineProps<{ frontmatter: any }>()
1017
18+
// Import all blog posts metadata
19+
const modules = import.meta.glob('/pages/blog/*.md')
20+
const blogPosts: Record<string, any> = {}
21+
22+
// Load all blog posts on mount
23+
onMounted(async () => {
24+
await Promise.all(
25+
Object.entries(modules).map(async ([path, loader]) => {
26+
const mod = await loader() as any
27+
blogPosts[path] = mod
28+
})
29+
)
30+
})
31+
32+
// Add computed property for suggested posts paths
33+
const hasSuggestedPosts = computed(() =>
34+
frontmatter.suggestedPosts &&
35+
Array.isArray(frontmatter.suggestedPosts) &&
36+
frontmatter.suggestedPosts.length > 0
37+
)
38+
39+
// Initialize suggestedPostsData ref
40+
const suggestedPostsData = ref<SuggestedPost[]>([])
41+
42+
// Watch for blog posts loading and update suggested posts
43+
watch(blogPosts, () => {
44+
if (!hasSuggestedPosts.value) return
45+
46+
try {
47+
const posts = frontmatter.suggestedPosts.map((path: string) => {
48+
const fullPath = `/pages${path}.md`
49+
const post = blogPosts[fullPath]
50+
return {
51+
path,
52+
title: post?.frontmatter?.title || path.split('/').pop()?.replace(/-/g, ' ') || 'Related Post',
53+
cover: post?.frontmatter?.cover,
54+
description: post?.frontmatter?.description
55+
} as SuggestedPost
56+
})
57+
suggestedPostsData.value = posts
58+
} catch (error) {
59+
console.error('Error fetching suggested posts:', error)
60+
}
61+
}, { immediate: true })
62+
1163
useHead({
1264
title: 'SomosNLP - Democratizando el NLP en español',
1365
meta: [
@@ -117,6 +169,23 @@ const linkUrl = computed(() => `https://www.linkedin.com/sharing/share-offsite/?
117169
🤗
118170
</IconButtonLink>
119171
</div>
172+
<div v-if="hasSuggestedPosts && suggestedPostsData.length > 0" class="mt-12">
173+
<hr class="mb-8" />
174+
<h3 class="text-xl font-bold mb-6">Artículos relacionados</h3>
175+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
176+
<div v-for="post in suggestedPostsData" :key="post.path"
177+
class="border rounded-lg overflow-hidden hover:shadow-lg transition-shadow">
178+
<RouterLink :to="post.path" class="block">
179+
<img v-if="post.cover" :src="post.cover" :alt="post.title"
180+
class="w-full h-48 object-cover" />
181+
<div class="p-4">
182+
<h4 class="text-lg font-semibold">{{ post.title }}</h4>
183+
<p v-if="post.description" class="mt-2 text-sm text-gray-600">{{ post.description }}</p>
184+
</div>
185+
</RouterLink>
186+
</div>
187+
</div>
188+
</div>
120189
<div v-if="$route.path.startsWith('/blog')" class="text-md text-center">
121190
<hr class="mt-8 mb-12" />
122191
<a target="_blank"

0 commit comments

Comments
 (0)