|
|
@ -1,8 +1,8 @@ |
|
|
|
import type { MarkdownFileType } from './file'; |
|
|
|
import type { MarkdownFileType } from './file'; |
|
|
|
import type { AuthorFileType } from './author.ts'; |
|
|
|
import type { AuthorFileType } from './author.ts'; |
|
|
|
import { getAllAuthors } from './author.ts'; |
|
|
|
import { getAllAuthors } from './author.ts'; |
|
|
|
import type {GuideFileType} from "./guide.ts"; |
|
|
|
import type { GuideFileType } from './guide.ts'; |
|
|
|
import {getAllGuides} from "./guide.ts"; |
|
|
|
import { getAllGuides } from './guide.ts'; |
|
|
|
|
|
|
|
|
|
|
|
export interface VideoFrontmatter { |
|
|
|
export interface VideoFrontmatter { |
|
|
|
title: string; |
|
|
|
title: string; |
|
|
@ -40,7 +40,7 @@ function videoPathToId(filePath: string): string { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function getVideosByAuthor( |
|
|
|
export async function getVideosByAuthor( |
|
|
|
authorId: string, |
|
|
|
authorId: string, |
|
|
|
): Promise<VideoFileType[]> { |
|
|
|
): Promise<VideoFileType[]> { |
|
|
|
const allVideos = await getAllVideos(); |
|
|
|
const allVideos = await getAllVideos(); |
|
|
|
|
|
|
|
|
|
|
@ -75,10 +75,20 @@ export async function getAllVideos(): Promise<VideoFileType[]> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function getVideoById(id: string): Promise<VideoFileType> { |
|
|
|
export async function getVideoById(id: string): Promise<VideoFileType> { |
|
|
|
const video = await import(`../data/videos/${id}.md`); |
|
|
|
const videoFilesMap: Record<string, VideoFileType> = |
|
|
|
|
|
|
|
import.meta.glob<VideoFileType>('../data/videos/*.md', { |
|
|
|
|
|
|
|
eager: true, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const videoFile = Object.values(videoFilesMap).find((videoFile) => { |
|
|
|
|
|
|
|
return videoPathToId(videoFile.file) === id; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (!videoFile) { |
|
|
|
|
|
|
|
throw new Error(`Video with ID ${id} not found`); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
...video, |
|
|
|
...videoFile, |
|
|
|
id: videoPathToId(video.file), |
|
|
|
id: videoPathToId(videoFile.file), |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|