fix: resolve circular import in index.js

- Fixed parse() function imports
- Removed problematic default export
- Added test-complete.js demo (temporary)

Tests: 11/11 passing 
Complete metadata extraction: 
This commit is contained in:
Jörg Lohrer 2025-10-01 16:16:44 +02:00
parent 2a96ba228e
commit 59e8ab2d72

View file

@ -33,6 +33,9 @@ export {
createForgejoClient
} from './forgejo-client.js'
// Für parse() Funktion
import { parseMarkdownFile as _parseMarkdownFile, parseMarkdownString as _parseMarkdownString } from './parser.js'
/**
* Convenience-Funktion: Parst Markdown von verschiedenen Quellen
* @param {string} source - Dateipfad, URL oder Markdown-String
@ -40,31 +43,18 @@ export {
* @returns {Promise<Object>} Parsed result
*/
export async function parse(source, options = {}) {
const { parseMarkdownFile, parseMarkdownString } = await import('./parser.js')
// Prüfe ob es ein Dateipfad ist
if (source.startsWith('/') || source.startsWith('./') || source.startsWith('../')) {
return parseMarkdownFile(source, options)
return _parseMarkdownFile(source, options)
}
// Prüfe ob es eine URL ist
if (source.startsWith('http://') || source.startsWith('https://')) {
const response = await fetch(source)
const markdown = await response.text()
return parseMarkdownString(markdown, options)
return _parseMarkdownString(markdown, options)
}
// Ansonsten als Markdown-String behandeln
return parseMarkdownString(source, options)
}
// Default Export
export default {
parse,
parseMarkdownFile,
parseMarkdownString,
ForgejoClient,
createForgejoClient,
extractYAML,
extractAMBMetadata
return _parseMarkdownString(source, options)
}