feat: improvements
This commit is contained in:
@@ -3,8 +3,7 @@ import { resolve } from 'node:path';
|
||||
import { parseEventSource } from '../src/data/event-parser';
|
||||
import { validateEventCollection } from '../src/data/event-schema';
|
||||
|
||||
const eventDirectory = resolve(process.cwd(), 'src/content/events');
|
||||
const publicDirectory = resolve(process.cwd(), 'public');
|
||||
const eventDirectory = resolve(process.cwd(), 'content/events');
|
||||
const eventFiles = readdirSync(eventDirectory).filter((file) => file.endsWith('.md')).sort();
|
||||
|
||||
if (eventFiles.length === 0) {
|
||||
@@ -14,10 +13,10 @@ if (eventFiles.length === 0) {
|
||||
const events = eventFiles.map((file) => {
|
||||
const filePath = resolve(eventDirectory, file);
|
||||
const event = parseEventSource(readFileSync(filePath, 'utf8'), file);
|
||||
const posterPath = resolve(publicDirectory, `.${event.poster}`);
|
||||
const posterPath = resolve(eventDirectory, event.poster);
|
||||
|
||||
if (!posterPath.startsWith(`${publicDirectory}/`) || !existsSync(posterPath)) {
|
||||
throw new Error(`${file}: poster does not exist in public/: ${event.poster}`);
|
||||
if (!posterPath.startsWith(`${eventDirectory}/`) || !existsSync(posterPath)) {
|
||||
throw new Error(`${file}: poster does not exist next to the event Markdown file: ${event.poster}`);
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
Reference in New Issue
Block a user