createApp({ setup() { const articles = ref([]); const sortedArticlesByPrefecture = computed(() => { const grouped = {}; articles.value.forEach(article => { const pref = article.prefecture || '未分類'; if (!grouped[pref]) grouped[pref] = []; grouped[pref].push(article); }); // 県内ソート(例:日付降順) Object.keys(grouped).forEach(pref => { grouped[pref].sort((a, b) => new Date(b.date) - new Date(a.date)); }); return grouped; }); onMounted(() => { fetch('./data/prefArticles.json') .then(res => res.json()) .then(data => { articles.value = data; }) .catch(err => { console.error('JSONの読み込みに失敗しました:', err); }); }); return { sortedArticlesByPrefecture }; } }).mount('#Prefecture');