@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
38 lines • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Lang = void 0;
exports.newLang = newLang;
/**
* Lang entity that manages source-to-language mappings
* TypeScript version of Go's Lang entity
*/
class Lang {
constructor(modules) {
this.sourceLangMap = new Map();
for (const module of modules) {
for (const mount of module.mounts()) {
this.sourceLangMap.set(mount.source(), mount.lang());
}
}
}
/**
* Get source language
* Returns a tuple of [language, exists] to match Go's return pattern
*/
getSourceLang(source) {
const lang = this.sourceLangMap.get(source);
if (lang !== undefined) {
return [lang, true];
}
return ['', false];
}
}
exports.Lang = Lang;
/**
* Creates a new Lang instance
* Factory function to match Go's NewLang function
*/
function newLang(modules) {
return new Lang(modules);
}
//# sourceMappingURL=lang.js.map