Update remote soul-content with local content

This commit is contained in:
卡若
2026-01-09 11:58:08 +08:00
parent 2bdf275cba
commit d781dc07ed
172 changed files with 16577 additions and 0 deletions

39
lib/markdown.ts Normal file
View File

@@ -0,0 +1,39 @@
import fs from 'fs'
import path from 'path'
import matter from 'gray-matter'
export interface MarkdownContent {
frontmatter: {
[key: string]: any
}
content: string
}
export function getMarkdownContent(filePath: string): MarkdownContent {
try {
const fullPath = path.join(process.cwd(), filePath)
// Ensure file exists
if (!fs.existsSync(fullPath)) {
console.warn(`File not found: ${filePath}`)
return {
frontmatter: {},
content: 'Content not found.'
}
}
const fileContents = fs.readFileSync(fullPath, 'utf8')
const { data, content } = matter(fileContents)
return {
frontmatter: data,
content,
}
} catch (error) {
console.error(`Error reading markdown file: ${filePath}`, error)
return {
frontmatter: {},
content: 'Error loading content.'
}
}
}