astro_avtourist/frontend/scripts/export-posts.ts
2026-05-07 17:16:25 +05:00

34 lines
No EOL
1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import PocketBase from 'pocketbase';
import fs from 'fs';
const PB_URL = 'http://127.0.0.1:8090';
const pb = new PocketBase(PB_URL);
async function exportPosts() {
console.log('📤 Экспорт постов в JSON\n');
const posts = await pb.collection('posts').getList(1, 500);
const exportData = posts.items.map(post => ({
id: post.id,
title: post.title,
slug: post.slug,
content: post.content,
description: post.description,
category: post.category,
categoryColor: post.categoryColor,
image: post.image,
date: post.date,
author: post.author,
readTime: post.readTime,
views: post.views,
draft: post.draft,
}));
fs.writeFileSync('./posts-export.json', JSON.stringify(exportData, null, 2), 'utf-8');
console.log(`Экспортировано ${exportData.length} постов в posts-export.json`);
console.log('\nТеперь нужно импортировать через админ-панель: https://avt-back.ru/_/');
}
exportPosts();