@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
1,901 lines (1,877 loc) • 3.22 MB
JavaScript
"use strict";
var __create2 = Object.create;
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __getProtoOf2 = Object.getPrototypeOf;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export2 = (target, all3) => {
for (var name in all3)
__defProp2(target, name, { get: all3[name], enumerable: true });
};
var __copyProps2 = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key3 of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key3) && key3 !== except)
__defProp2(to, key3, { get: () => from[key3], enumerable: !(desc = __getOwnPropDesc2(from, key3)) || desc.enumerable });
}
return to;
};
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
// pkg/log/types.ts
var init_types = __esm({
"pkg/log/types.ts"() {
"use strict";
}
});
// pkg/log/logger.ts
function New3(level = "info" /* INFO */) {
return new Logger({ level });
}
function NewWithConfig(config2) {
return new Logger(config2);
}
var util, Logger;
var init_logger = __esm({
"pkg/log/logger.ts"() {
"use strict";
util = __toESM2(require("util"));
init_types();
Logger = class _Logger {
config;
fields;
constructor(config2) {
this.config = {
enableCaller: true,
jsonFormat: true,
...config2
};
this.fields = {};
}
shouldLog(level) {
const levels = ["debug" /* DEBUG */, "info" /* INFO */, "warn" /* WARN */, "error" /* ERROR */, "fatal" /* FATAL */];
const configLevelIndex = levels.indexOf(this.config.level);
const msgLevelIndex = levels.indexOf(level);
return msgLevelIndex >= configLevelIndex;
}
getCaller() {
if (!this.config.enableCaller) {
return void 0;
}
const stack = new Error().stack;
if (!stack)
return void 0;
const lines = stack.split("\n");
const callerLine = lines[4];
if (!callerLine)
return void 0;
const match2 = callerLine.match(/at .* \((.+):(\d+):(\d+)\)/);
if (match2) {
const [, file, line] = match2;
const filename = file.split("/").pop();
return `${filename}:${line}`;
}
const simpleMatch = callerLine.match(/at (.+):(\d+):(\d+)/);
if (simpleMatch) {
const [, file, line] = simpleMatch;
const filename = file.split("/").pop();
return `${filename}:${line}`;
}
return void 0;
}
formatMessage(template, args) {
if (args.length === 0) {
return template;
}
return util.format(template, ...args);
}
writeLog(level, message) {
if (!this.shouldLog(level)) {
return;
}
const entry = {
level,
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
message,
...this.fields
};
const caller = this.getCaller();
if (caller) {
entry.caller = caller;
}
const output = this.config.jsonFormat ? JSON.stringify(entry) : this.formatPlainText(entry);
if (level === "error" /* ERROR */ || level === "fatal" /* FATAL */) {
process.stderr.write(output + "\n");
} else {
process.stdout.write(output + "\n");
}
if (level === "fatal" /* FATAL */) {
process.exit(1);
}
}
formatPlainText(entry) {
const parts = [entry.timestamp, entry.level.toUpperCase()];
if (entry.caller) {
parts.push(`[${entry.caller}]`);
}
parts.push(entry.message);
const extraFields = Object.keys(entry).filter((key3) => !["level", "timestamp", "message", "caller"].includes(key3)).map((key3) => `${key3}=${JSON.stringify(entry[key3])}`).join(" ");
if (extraFields) {
parts.push(extraFields);
}
return parts.join(" ");
}
// Direct logging methods
debug(message, ...args) {
this.writeLog("debug" /* DEBUG */, this.formatMessage(message, args));
}
info(message, ...args) {
this.writeLog("info" /* INFO */, this.formatMessage(message, args));
}
warn(message, ...args) {
this.writeLog("warn" /* WARN */, this.formatMessage(message, args));
}
error(message, ...args) {
this.writeLog("error" /* ERROR */, this.formatMessage(message, args));
}
fatal(message, ...args) {
this.writeLog("fatal" /* FATAL */, this.formatMessage(message, args));
}
// Formatted logging methods (printf-style)
debugf(template, ...args) {
this.writeLog("debug" /* DEBUG */, this.formatMessage(template, args));
}
infof(template, ...args) {
this.writeLog("info" /* INFO */, this.formatMessage(template, args));
}
warnf(template, ...args) {
this.writeLog("warn" /* WARN */, this.formatMessage(template, args));
}
errorf(template, ...args) {
this.writeLog("error" /* ERROR */, this.formatMessage(template, args));
}
fatalf(template, ...args) {
this.writeLog("fatal" /* FATAL */, this.formatMessage(template, args));
}
// Create a new logger with additional fields
with(fields) {
const newLogger = new _Logger(this.config);
newLogger.fields = { ...this.fields, ...fields };
return newLogger;
}
};
}
});
// pkg/log/http.ts
var init_http = __esm({
"pkg/log/http.ts"() {
"use strict";
}
});
// pkg/log/manager.ts
function getDomainLogger(domain, additionalFields) {
return globalLoggerManager.getLogger(domain, additionalFields);
}
var LoggerManager, globalLoggerManager;
var init_manager = __esm({
"pkg/log/manager.ts"() {
"use strict";
init_logger();
init_types();
LoggerManager = class _LoggerManager {
static instance;
globalConfig;
loggers;
constructor() {
this.globalConfig = {
level: "error" /* ERROR */,
enableCaller: true,
jsonFormat: true
};
this.loggers = /* @__PURE__ */ new Map();
}
/**
* Get the singleton instance of LoggerManager
*/
static getInstance() {
if (!_LoggerManager.instance) {
_LoggerManager.instance = new _LoggerManager();
}
return _LoggerManager.instance;
}
/**
* Set global logger configuration
* This affects all new logger instances created after this call
*/
setGlobalConfig(config2) {
this.globalConfig = { ...this.globalConfig, ...config2 };
this.loggers.clear();
}
/**
* Get global logger configuration
*/
getGlobalConfig() {
return { ...this.globalConfig };
}
/**
* Get logger for a specific domain/component
* Creates and caches logger instances per domain
*/
getLogger(domain, additionalFields) {
const cacheKey = domain + (additionalFields ? JSON.stringify(additionalFields) : "");
if (!this.loggers.has(cacheKey)) {
const logger = NewWithConfig(this.globalConfig);
const fields = {
domain,
...additionalFields
};
const domainLogger = logger.with(fields);
this.loggers.set(cacheKey, domainLogger);
}
return this.loggers.get(cacheKey);
}
/**
* Get logger for a specific domain with component information
*/
getComponentLogger(domain, component, additionalFields) {
const fields = {
component,
...additionalFields
};
return this.getLogger(domain, fields);
}
/**
* Clear all cached loggers
* Useful when you want to force recreation with new configuration
*/
clearCache() {
this.loggers.clear();
}
/**
* Get all cached logger domains
*/
getCachedDomains() {
return Array.from(this.loggers.keys());
}
/**
* Set log level for all existing and future loggers
*/
setLogLevel(level) {
this.setGlobalConfig({ level });
}
/**
* Enable or disable caller information for all loggers
*/
setCallerEnabled(enabled) {
this.setGlobalConfig({ enableCaller: enabled });
}
/**
* Set JSON format for all loggers
*/
setJsonFormat(enabled) {
this.setGlobalConfig({ jsonFormat: enabled });
}
};
globalLoggerManager = LoggerManager.getInstance();
}
});
// pkg/log/index.ts
var defaultLogger;
var init_log = __esm({
"pkg/log/index.ts"() {
"use strict";
init_types();
init_logger();
init_http();
init_manager();
init_logger();
init_types();
defaultLogger = New3("info" /* INFO */);
}
});
// pkg/page-filter/index.ts
function setPageFilter(tasks2) {
pageFilter.setFilter(tasks2);
}
function clearPageFilter() {
pageFilter.clearFilter();
}
function shouldProcessPage(language2, pagePath) {
return pageFilter.shouldProcess(language2, pagePath);
}
var log, PageFilterManager, pageFilter;
var init_page_filter = __esm({
"pkg/page-filter/index.ts"() {
"use strict";
init_log();
log = getDomainLogger("pkg", { component: "page-filter" });
PageFilterManager = class {
filterSet = null;
currentLanguage = null;
/**
* 设置页面过滤器
* @param tasks Array of {language, pagePath}
*/
setFilter(tasks2) {
this.filterSet = /* @__PURE__ */ new Set();
for (const task of tasks2) {
const key3 = `${task.language}:${task.pagePath}`;
this.filterSet.add(key3);
}
log.debug(`Page filter set: ${tasks2.length} tasks`);
}
/**
* 设置当前处理的语言
*/
setCurrentLanguage(language2) {
this.currentLanguage = language2;
}
/**
* 清除过滤器
*/
clearFilter() {
this.filterSet = null;
this.currentLanguage = null;
log.debug("Page filter cleared");
}
/**
* 检查是否应该处理此页面 (O(1) 查找)
*
* @param language 语言代码
* @param pagePath 页面路径
* @returns true 如果应该处理,false 如果应该跳过
*/
shouldProcess(language2, pagePath) {
if (!this.filterSet) {
return true;
}
const key3 = `${language2}:${pagePath}`;
return this.filterSet.has(key3);
}
/**
* 获取过滤器大小
*/
getFilterSize() {
return this.filterSet?.size ?? 0;
}
};
pageFilter = new PageFilterManager();
}
});
// internal/domain/config/type.ts
var ConfigError, ErrConfigNotFound, ErrInvalidConfig, ErrWorkspaceNotFound, ErrConfigFileNotFound, ErrInvalidConfigFormat;
var init_type = __esm({
"internal/domain/config/type.ts"() {
"use strict";
ConfigError = class extends Error {
constructor(message, code2) {
super(message);
this.code = code2;
this.name = "ConfigError";
}
};
ErrConfigNotFound = new ConfigError("configuration not found", "CONFIG_NOT_FOUND");
ErrInvalidConfig = new ConfigError("invalid configuration", "INVALID_CONFIG");
ErrWorkspaceNotFound = new ConfigError("workspace not found", "WORKSPACE_NOT_FOUND");
ErrConfigFileNotFound = new ConfigError("configuration file not found", "CONFIG_FILE_NOT_FOUND");
ErrInvalidConfigFormat = new ConfigError("invalid configuration format", "INVALID_CONFIG_FORMAT");
}
});
// internal/domain/config/entity/config.ts
function newConfig(configSourceFs, provider, root2, dir2, module2, service, social, language2, taxonomy, markdown) {
return new Config(configSourceFs, provider, root2, dir2, module2, service, social, language2, taxonomy, markdown);
}
var Config;
var init_config = __esm({
"internal/domain/config/entity/config.ts"() {
"use strict";
Config = class {
configSourceFs;
provider;
root;
dir;
module;
service;
social;
language;
taxonomy;
markdown;
constructor(configSourceFs, provider, root2, dir2, module2, service, social, language2, taxonomy, markdown) {
this.configSourceFs = configSourceFs;
this.provider = provider;
this.root = root2;
this.dir = dir2;
this.module = module2;
this.service = service;
this.social = social;
this.language = language2;
this.taxonomy = taxonomy;
this.markdown = markdown;
}
fs() {
return this.configSourceFs;
}
getProvider() {
return this.provider;
}
theme() {
return this.root.defaultTheme();
}
getDir() {
return this.dir;
}
/**
* Get Root entity
*/
getRoot() {
return this.root;
}
/**
* Get Module entity
*/
getModule() {
return this.module;
}
/**
* Get Service entity
*/
getService() {
return this.service;
}
/**
* Get Social entity
*/
getSocial() {
return this.social;
}
/**
* Get Language entity (optional)
*/
getLanguage() {
return this.language;
}
/**
* Get Taxonomy entity (optional)
*/
getTaxonomy() {
return this.taxonomy;
}
/**
* Get Markdown entity
*/
getMarkdown() {
return this.markdown;
}
/**
* Set Language entity
*/
setLanguage(language2) {
this.language = language2;
}
/**
* Set Taxonomy entity
*/
setTaxonomy(taxonomy) {
this.taxonomy = taxonomy;
}
/**
* Set Markdown entity
*/
setMarkdown(markdown) {
this.markdown = markdown;
}
/**
* Validate the configuration
*/
validate() {
let valid4 = true;
if (this.language) {
valid4 = valid4 && this.language.validate();
}
if (this.markdown) {
valid4 = valid4 && this.markdown.validate();
}
return valid4;
}
};
}
});
// internal/domain/config/vo/root.ts
function decodeRootConfig(data) {
return {
baseURL: data.baseurl || DefaultRootConfig.baseURL,
title: data.title || DefaultRootConfig.title,
theme: data.theme || DefaultRootConfig.theme,
timeout: data.timeout || DefaultRootConfig.timeout,
contentDir: data.contentDir || DefaultRootConfig.contentDir,
dataDir: data.dataDir || DefaultRootConfig.dataDir,
layoutDir: data.layoutDir || DefaultRootConfig.layoutDir,
staticDir: data.staticDir || DefaultRootConfig.staticDir,
archetypeDir: data.archetypeDir || DefaultRootConfig.archetypeDir,
assetDir: data.assetDir || DefaultRootConfig.assetDir,
publishDir: data.publishDir || DefaultRootConfig.publishDir,
buildDrafts: data.buildDrafts !== void 0 ? data.buildDrafts : DefaultRootConfig.buildDrafts,
buildExpired: data.buildExpired !== void 0 ? data.buildExpired : DefaultRootConfig.buildExpired,
buildFuture: data.buildFuture !== void 0 ? data.buildFuture : DefaultRootConfig.buildFuture,
copyright: data.copyright || DefaultRootConfig.copyright,
defaultContentLanguage: data.defaultContentLanguage || DefaultRootConfig.defaultContentLanguage,
defaultContentLanguageInSubdir: data.defaultContentLanguageInSubdir !== void 0 ? data.defaultContentLanguageInSubdir : DefaultRootConfig.defaultContentLanguageInSubdir,
disableAliases: data.disableAliases !== void 0 ? data.disableAliases : DefaultRootConfig.disableAliases,
disablePathToLower: data.disablePathToLower !== void 0 ? data.disablePathToLower : DefaultRootConfig.disablePathToLower,
disableKinds: data.disableKinds || DefaultRootConfig.disableKinds,
disableLanguages: data.disableLanguages || DefaultRootConfig.disableLanguages,
renderSegments: data.renderSegments || DefaultRootConfig.renderSegments,
disableHugoGeneratorInject: data.disableHugoGeneratorInject !== void 0 ? data.disableHugoGeneratorInject : DefaultRootConfig.disableHugoGeneratorInject,
disableLiveReload: data.disableLiveReload !== void 0 ? data.disableLiveReload : DefaultRootConfig.disableLiveReload,
enableEmoji: data.enableEmoji !== void 0 ? data.enableEmoji : DefaultRootConfig.enableEmoji
};
}
var DefaultRootConfig;
var init_root = __esm({
"internal/domain/config/vo/root.ts"() {
"use strict";
DefaultRootConfig = {
baseURL: "",
title: "",
theme: [],
timeout: "30s",
contentDir: "content",
dataDir: "data",
layoutDir: "layouts",
staticDir: "static",
archetypeDir: "archetypes",
assetDir: "assets",
publishDir: "public",
buildDrafts: false,
buildExpired: false,
buildFuture: false,
copyright: "",
defaultContentLanguage: "en",
defaultContentLanguageInSubdir: false,
disableAliases: false,
disablePathToLower: false,
disableKinds: [],
disableLanguages: [],
renderSegments: [],
disableHugoGeneratorInject: false,
disableLiveReload: false,
enableEmoji: false
};
}
});
// internal/domain/config/entity/root.ts
function newRoot(data, params = {}) {
const rootConfig = decodeRootConfig(data);
return new Root(rootConfig, params);
}
var Root;
var init_root2 = __esm({
"internal/domain/config/entity/root.ts"() {
"use strict";
init_root();
Root = class {
rootConfig;
rootParams;
constructor(rootConfig, rootParams = {}) {
this.rootConfig = rootConfig;
this.rootParams = rootParams;
}
/**
* Get the default theme
*/
defaultTheme() {
return this.rootConfig.theme.length > 0 ? this.rootConfig.theme[0] : "";
}
/**
* Get the compiled timeout duration
*/
compiledTimeout() {
const timeout = this.rootConfig.timeout;
if (/^\d+$/.test(timeout)) {
return parseInt(timeout, 10) * 1e3;
}
const match2 = timeout.match(/^(\d+)([smh])$/);
if (match2) {
const value2 = parseInt(match2[1], 10);
const unit = match2[2];
switch (unit) {
case "s":
return value2 * 1e3;
case "m":
return value2 * 60 * 1e3;
case "h":
return value2 * 60 * 60 * 1e3;
}
}
return 3e4;
}
/**
* Get the base URL
*/
baseUrl() {
return this.rootConfig.baseURL;
}
/**
* Get configuration parameters
*/
configParams() {
return this.rootParams;
}
/**
* Get site title
*/
siteTitle() {
return this.rootConfig.title;
}
/**
* Get the root configuration
*/
getRootConfig() {
return this.rootConfig;
}
/**
* Get theme list
*/
getThemes() {
return this.rootConfig.theme;
}
/**
* Get default content language
*/
getDefaultContentLanguage() {
return this.rootConfig.defaultContentLanguage;
}
/**
* Check if drafts should be built
*/
shouldBuildDrafts() {
return this.rootConfig.buildDrafts;
}
/**
* Check if future content should be built
*/
shouldBuildFuture() {
return this.rootConfig.buildFuture;
}
/**
* Check if expired content should be built
*/
shouldBuildExpired() {
return this.rootConfig.buildExpired;
}
};
}
});
// internal/domain/config/vo/module.ts
function decodeModuleConfig(data) {
const config2 = {
mounts: [],
imports: []
};
if (data.mounts && Array.isArray(data.mounts)) {
config2.mounts = data.mounts.map((mount) => ({
source: mount.source || "",
target: mount.target || "",
lang: mount.lang
}));
}
if (data.imports && Array.isArray(data.imports)) {
config2.imports = data.imports.map((imp) => ({
path: imp.path || "",
url: imp.url,
version: imp.version,
mounts: imp.mounts || []
}));
}
return config2;
}
var init_module = __esm({
"internal/domain/config/vo/module.ts"() {
"use strict";
}
});
// internal/domain/config/entity/module.ts
function newModule(data) {
const moduleConfig = decodeModuleConfig(data);
return new Module(moduleConfig);
}
var Module;
var init_module2 = __esm({
"internal/domain/config/entity/module.ts"() {
"use strict";
init_module();
Module = class {
moduleConfig;
constructor(moduleConfig) {
this.moduleConfig = moduleConfig;
}
/**
* Get import paths from module imports
*/
importPaths() {
return this.moduleConfig.imports.map((imp) => imp.path);
}
/**
* Get the module configuration
*/
getModuleConfig() {
return this.moduleConfig;
}
/**
* Get all imports
*/
getImports() {
return this.moduleConfig.imports;
}
/**
* Get all mounts
*/
getMounts() {
return this.moduleConfig.mounts;
}
/**
* Get import count
*/
importCount() {
return this.moduleConfig.imports.length;
}
/**
* Get mount count
*/
mountCount() {
return this.moduleConfig.mounts.length;
}
/**
* Check if module has imports
*/
hasImports() {
return this.moduleConfig.imports.length > 0;
}
/**
* Check if module has mounts
*/
hasMounts() {
return this.moduleConfig.mounts.length > 0;
}
/**
* Find import by path
*/
findImport(path29) {
return this.moduleConfig.imports.find((imp) => imp.path === path29);
}
/**
* Find mount by source
*/
findMount(source) {
return this.moduleConfig.mounts.find((mount) => mount.source === source);
}
};
}
});
// internal/domain/config/vo/service.ts
function decodeServiceConfig(services) {
const config2 = {
disqus: { ...DefaultServiceConfig.disqus },
googleAnalytics: { ...DefaultServiceConfig.googleAnalytics },
rss: { ...DefaultServiceConfig.rss },
x: { ...DefaultServiceConfig.x }
};
if (services) {
if (services.disqus) {
config2.disqus.shortname = services.disqus.shortname || config2.disqus.shortname;
}
if (services.googleAnalytics) {
config2.googleAnalytics.id = services.googleAnalytics.id || config2.googleAnalytics.id;
}
if (services.rss) {
config2.rss.limit = services.rss.limit !== void 0 ? services.rss.limit : config2.rss.limit;
}
}
return config2;
}
var DefaultServiceConfig;
var init_service = __esm({
"internal/domain/config/vo/service.ts"() {
"use strict";
DefaultServiceConfig = {
disqus: {
disable: false,
shortname: ""
},
googleAnalytics: {
disable: false,
respectDoNotTrack: false,
id: ""
},
rss: {
limit: 0
},
x: {
respectDoNotTrack: false,
disableInlineCSS: false
}
};
}
});
// internal/domain/config/entity/service.ts
function newService(data) {
const serviceConfig = decodeServiceConfig(data);
return new Service(serviceConfig);
}
var Service;
var init_service2 = __esm({
"internal/domain/config/entity/service.ts"() {
"use strict";
init_service();
Service = class {
serviceConfig;
constructor(serviceConfig) {
this.serviceConfig = serviceConfig;
}
/**
* Check if Google Analytics is enabled
*/
isGoogleAnalyticsEnabled() {
return !this.serviceConfig.googleAnalytics.disable;
}
/**
* Get Google Analytics ID
*/
googleAnalyticsID() {
return this.serviceConfig.googleAnalytics.id;
}
/**
* Check if Google Analytics should respect Do Not Track
*/
isGoogleAnalyticsRespectDoNotTrack() {
return this.serviceConfig.googleAnalytics.respectDoNotTrack;
}
/**
* Check if Disqus is enabled
*/
isDisqusEnabled() {
return !this.serviceConfig.disqus.disable;
}
disqusShortname() {
return this.serviceConfig.disqus.shortname;
}
isXRespectDoNotTrack() {
return this.serviceConfig.x.respectDoNotTrack;
}
isXDisableInlineCSS() {
return this.serviceConfig.x.disableInlineCSS;
}
/**
* Get RSS limit
*/
rssLimit() {
return this.serviceConfig.rss.limit;
}
/**
* Get the service configuration
*/
getServiceConfig() {
return this.serviceConfig;
}
/**
* Get Google Analytics configuration
*/
getGoogleAnalytics() {
return this.serviceConfig.googleAnalytics;
}
/**
* Get Disqus configuration
*/
getDisqus() {
return this.serviceConfig.disqus;
}
/**
* Get RSS configuration
*/
getRSS() {
return this.serviceConfig.rss;
}
/**
* Check if any service is enabled
*/
hasEnabledServices() {
return this.isGoogleAnalyticsEnabled() || this.isDisqusEnabled();
}
};
}
});
// pkg/lang/data.ts
var LTR_LANGUAGES, RTL_LANGUAGES, ALL_LANGUAGES, LANGUAGE_MAP, CODE_NAME_MAP;
var init_data = __esm({
"pkg/lang/data.ts"() {
"use strict";
LTR_LANGUAGES = [
{
code: "en",
name: "English",
direction: "ltr",
englishName: "English"
},
{
code: "zh",
name: "\u4E2D\u6587",
direction: "ltr",
englishName: "Chinese"
},
{
code: "ja",
name: "\u65E5\u672C\u8A9E",
direction: "ltr",
englishName: "Japanese"
},
{
code: "ko",
name: "\uD55C\uAD6D\uC5B4",
direction: "ltr",
englishName: "Korean"
},
{
code: "fr",
name: "Fran\xE7ais",
direction: "ltr",
englishName: "French"
},
{
code: "de",
name: "Deutsch",
direction: "ltr",
englishName: "German"
},
{
code: "es",
name: "Espa\xF1ol",
direction: "ltr",
englishName: "Spanish"
},
{
code: "pt",
name: "Portugu\xEAs",
direction: "ltr",
englishName: "Portuguese"
},
{
code: "ru",
name: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
direction: "ltr",
englishName: "Russian"
},
{
code: "hi",
name: "\u0939\u093F\u0902\u0926\u0940",
direction: "ltr",
englishName: "Hindi"
},
{
code: "it",
name: "Italiano",
direction: "ltr",
englishName: "Italian"
},
{
code: "nl",
name: "Nederlands",
direction: "ltr",
englishName: "Dutch"
},
{
code: "tr",
name: "T\xFCrk\xE7e",
direction: "ltr",
englishName: "Turkish"
},
{
code: "vi",
name: "Ti\u1EBFng Vi\u1EC7t",
direction: "ltr",
englishName: "Vietnamese"
},
{
code: "th",
name: "\u0E44\u0E17\u0E22",
direction: "ltr",
englishName: "Thai"
}
];
RTL_LANGUAGES = [
// Future RTL language support will be added here
// Examples:
// {
// code: 'ar',
// name: 'العربية',
// direction: 'rtl',
// englishName: 'Arabic'
// },
// {
// code: 'he',
// name: 'עברית',
// direction: 'rtl',
// englishName: 'Hebrew'
// },
// {
// code: 'fa',
// name: 'فارسی',
// direction: 'rtl',
// englishName: 'Persian'
// }
];
ALL_LANGUAGES = [
...LTR_LANGUAGES,
...RTL_LANGUAGES
];
LANGUAGE_MAP = ALL_LANGUAGES.reduce(
(map2, lang2) => {
map2[lang2.code] = lang2;
return map2;
},
{}
);
CODE_NAME_MAP = ALL_LANGUAGES.reduce(
(map2, lang2) => {
map2[lang2.code] = lang2.name;
return map2;
},
{}
);
}
});
// pkg/lang/service.ts
function getLanguageService() {
if (!serviceInstance) {
serviceInstance = new DefaultLanguageService();
}
return serviceInstance;
}
function createLanguageService() {
return new DefaultLanguageService();
}
var DefaultLanguageService, serviceInstance;
var init_service3 = __esm({
"pkg/lang/service.ts"() {
"use strict";
init_data();
DefaultLanguageService = class {
/**
* Get all supported language codes
*/
getAllCodes() {
return ALL_LANGUAGES.map((lang2) => lang2.code);
}
/**
* Get all supported language names
*/
getAllNames() {
return ALL_LANGUAGES.map((lang2) => lang2.name);
}
/**
* Get language codes for a specific direction
*/
getCodesByDirection(direction) {
const languages2 = direction === "ltr" ? LTR_LANGUAGES : RTL_LANGUAGES;
return languages2.map((lang2) => lang2.code);
}
/**
* Get language names for a specific direction
*/
getNamesByDirection(direction) {
const languages2 = direction === "ltr" ? LTR_LANGUAGES : RTL_LANGUAGES;
return languages2.map((lang2) => lang2.name);
}
/**
* Get code-to-name mapping for all languages
*/
getCodeNameMap() {
return { ...CODE_NAME_MAP };
}
/**
* Get code-to-name mapping for a specific direction
*/
getCodeNameMapByDirection(direction) {
const languages2 = direction === "ltr" ? LTR_LANGUAGES : RTL_LANGUAGES;
return languages2.reduce((map2, lang2) => {
map2[lang2.code] = lang2.name;
return map2;
}, {});
}
/**
* Get language name by code
*/
getNameByCode(code2) {
return LANGUAGE_MAP[code2]?.name;
}
/**
* Get complete language information by code
*/
getLanguageInfo(code2) {
const info = LANGUAGE_MAP[code2];
return info ? { ...info } : void 0;
}
/**
* Check if a language code is supported
*/
isSupported(code2) {
return code2 in LANGUAGE_MAP;
}
/**
* Get language direction by code
*/
getDirection(code2) {
return LANGUAGE_MAP[code2]?.direction;
}
/**
* Check if a language is LTR (Left-to-Right)
*/
isLTR(code2) {
return LANGUAGE_MAP[code2]?.direction === "ltr";
}
/**
* Check if a language is RTL (Right-to-Left)
*/
isRTL(code2) {
return LANGUAGE_MAP[code2]?.direction === "rtl";
}
};
serviceInstance = null;
}
});
// pkg/lang/index.ts
var lang_exports = {};
__export2(lang_exports, {
ALL_LANGUAGES: () => ALL_LANGUAGES,
CODE_NAME_MAP: () => CODE_NAME_MAP,
DefaultLanguageService: () => DefaultLanguageService,
LANGUAGE_MAP: () => LANGUAGE_MAP,
LTR_LANGUAGES: () => LTR_LANGUAGES,
RTL_LANGUAGES: () => RTL_LANGUAGES,
createLanguageService: () => createLanguageService,
getLanguageService: () => getLanguageService,
lang: () => lang,
languages: () => languages
});
var lang, languages;
var init_lang = __esm({
"pkg/lang/index.ts"() {
"use strict";
init_data();
init_service3();
init_service3();
lang = getLanguageService();
languages = {
/**
* Get all language codes
*/
getAllCodes: () => lang.getAllCodes(),
/**
* Get all language names
*/
getAllNames: () => lang.getAllNames(),
/**
* Get language codes by direction
*/
getCodesByDirection: (direction) => lang.getCodesByDirection(direction),
/**
* Get language names by direction
*/
getNamesByDirection: (direction) => lang.getNamesByDirection(direction),
/**
* Get code-name mapping
*/
getCodeNameMap: () => lang.getCodeNameMap(),
/**
* Get code-name mapping by direction
*/
getCodeNameMapByDirection: (direction) => lang.getCodeNameMapByDirection(direction),
/**
* Get language name by code
*/
getNameByCode: (code2) => lang.getNameByCode(code2),
/**
* Get language info by code
*/
getLanguageInfo: (code2) => lang.getLanguageInfo(code2),
/**
* Check if language is supported
*/
isSupported: (code2) => lang.isSupported(code2),
/**
* Get language direction
*/
getDirection: (code2) => lang.getDirection(code2),
/**
* Check if language is LTR
*/
isLTR: (code2) => lang.isLTR(code2),
/**
* Check if language is RTL
*/
isRTL: (code2) => lang.isRTL(code2)
};
}
});
// internal/domain/config/vo/language.ts
function decodeLanguageConfig(data) {
const configs = {};
if (!data || Object.keys(data).length === 0) {
configs["en"] = {
...DefaultLanguageConfig,
title: data?.title || DefaultLanguageConfig.title,
params: data?.params || DefaultLanguageConfig.params
};
return configs;
}
for (const [langCode, langData] of Object.entries(data)) {
const langConfig = langData;
const languageName = languages.getNameByCode(langCode) || langCode;
configs[langCode] = {
languageCode: langCode,
languageName,
title: langConfig.title || data.title || "",
weight: langConfig.weight !== void 0 ? langConfig.weight : 0,
contentDir: langConfig.contentDir || "content",
disabled: langConfig.disabled !== void 0 ? langConfig.disabled : false,
params: langConfig.params || data.params || {}
};
}
return configs;
}
function validateLanguageConfig(configs, defaultLang) {
return Object.prototype.hasOwnProperty.call(configs, defaultLang);
}
var DefaultLanguageConfig;
var init_language = __esm({
"internal/domain/config/vo/language.ts"() {
"use strict";
init_lang();
DefaultLanguageConfig = {
languageCode: "en",
languageName: "English",
title: "",
weight: 0,
contentDir: "content",
disabled: false,
params: {}
};
}
});
// internal/domain/config/entity/language.ts
function newLanguage(data) {
const configs = decodeLanguageConfig(data);
return new Language(configs);
}
var Language;
var init_language2 = __esm({
"internal/domain/config/entity/language.ts"() {
"use strict";
init_language();
Language = class {
defaultLang;
configs;
indices;
constructor(configs) {
this.configs = configs;
this.defaultLang = this.calculateDefaultLanguage();
this.indices = [];
this.setIndices();
}
/**
* Calculate default language based on weight (smallest weight wins)
*/
calculateDefaultLanguage() {
if (Object.keys(this.configs).length === 0) {
return "en";
}
let defaultLang = "";
let minWeight = Number.MAX_SAFE_INTEGER;
for (const [langCode, config2] of Object.entries(this.configs)) {
if (config2.weight < minWeight) {
minWeight = config2.weight;
defaultLang = langCode;
}
}
return defaultLang || Object.keys(this.configs)[0];
}
/**
* Get all language configurations
*/
languages() {
return Object.values(this.configs);
}
/**
* Get default language
*/
defaultLanguage() {
return this.defaultLang;
}
/**
* Check if a language is valid
*/
isLanguageValid(lang2) {
return Object.prototype.hasOwnProperty.call(this.configs, lang2);
}
/**
* Get other language keys (excluding default)
*/
otherLanguageKeys() {
return Object.keys(this.configs).filter((lang2) => lang2 !== this.defaultLang);
}
/**
* Get relative directory for a language
*/
getRelDir(name, langKey) {
const config2 = this.configs[langKey];
if (!config2) {
throw new Error(`Language "${langKey}" not found`);
}
return config2.contentDir || "content";
}
/**
* Validate language configuration
*/
validate() {
return validateLanguageConfig(this.configs, this.defaultLang);
}
/**
* Set language indices (ordered list)
*/
setIndices() {
const languages2 = [];
if (this.configs[this.defaultLang]) {
languages2.push(this.defaultLang);
}
for (const lang2 of Object.keys(this.configs)) {
if (lang2 !== this.defaultLang) {
languages2.push(lang2);
}
}
this.indices = languages2;
}
/**
* Get language keys in order
*/
languageKeys() {
return [...this.indices];
}
/**
* Get language indexes
*/
languageIndexes() {
return this.indices.map((_, index2) => index2);
}
/**
* Get language index by language code
*/
getLanguageIndex(lang2) {
const index2 = this.indices.indexOf(lang2);
if (index2 === -1) {
throw new Error("Language not found in indices");
}
return index2;
}
/**
* Get language by index
*/
getLanguageByIndex(idx) {
if (idx < 0 || idx >= this.indices.length) {
throw new Error("Language index out of range");
}
return this.indices[idx];
}
/**
* Get language name by language code
*/
getLanguageName(lang2) {
const config2 = this.configs[lang2];
return config2 ? config2.languageName : "";
}
/**
* Get language configuration by language code
*/
getLanguageConfig(lang2) {
return this.configs[lang2];
}
/**
* Get all language configurations
*/
getConfigs() {
return this.configs;
}
};
}
});
// internal/domain/config/vo/taxonomy.ts
function cleanTreeKey(...elems) {
let s2 = "";
if (elems.length > 0) {
s2 = elems[0];
if (elems.length > 1) {
s2 = elems.join("/");
}
}
s2 = s2.replace(/^[.\s/]+|[.\s/]+$/g, "");
s2 = s2.toLowerCase();
s2 = s2.replace(/\\/g, "/");
if (s2 === "" || s2 === "/") {
return "";
}
if (!s2.startsWith("/")) {
s2 = "/" + s2;
}
return s2;
}
function setupTaxonomyViews(taxonomies) {
const views = [];
for (const [singular, plural] of Object.entries(taxonomies)) {
views.push({
singular,
plural,
pluralTreeKey: cleanTreeKey(plural)
});
}
views.sort((a, b) => a.plural.localeCompare(b.plural));
return views;
}
function decodeTaxonomyConfig(data) {
if (data.taxonomies && typeof data.taxonomies === "object") {
const taxonomies = {};
for (const [key3, value2] of Object.entries(data.taxonomies)) {
if (typeof value2 === "string") {
taxonomies[key3] = value2;
}
}
return taxonomies;
}
return { ...DefaultTaxonomies };
}
var DefaultTaxonomies;
var init_taxonomy = __esm({
"internal/domain/config/vo/taxonomy.ts"() {
"use strict";
DefaultTaxonomies = {
tag: "tags",
category: "categories"
};
}
});
// internal/domain/config/entity/taxonomy.ts
function newTaxonomy(data) {
const taxonomies = decodeTaxonomyConfig(data);
return new Taxonomy(taxonomies);
}
var Taxonomy;
var init_taxonomy2 = __esm({
"internal/domain/config/entity/taxonomy.ts"() {
"use strict";
init_taxonomy();
Taxonomy = class {
taxonomies;
views;
viewsByTreeKey;
constructor(taxonomies) {
this.taxonomies = taxonomies;
this.views = [];
this.viewsByTreeKey = {};
this.setupViews();
}
/**
* Get taxonomy views
*/
getViews() {
return [...this.views];
}
/**
* Get taxonomies configuration
*/
getTaxonomies() {
return { ...this.taxonomies };
}
/**
* Get view by tree key
*/
getViewByTreeKey(treeKey) {
return this.viewsByTreeKey[treeKey];
}
/**
* Check if taxonomy exists
*/
hasTaxonomy(singular) {
return Object.prototype.hasOwnProperty.call(this.taxonomies, singular);
}
/**
* Get plural form of taxonomy
*/
getPluralForm(singular) {
return this.taxonomies[singular];
}
/**
* Get singular form from plural
*/
getSingularForm(plural) {
for (const [singular, pluralForm] of Object.entries(this.taxonomies)) {
if (pluralForm === plural) {
return singular;
}
}
return void 0;
}
/**
* Get all singular forms
*/
getSingularForms() {
return Object.keys(this.taxonomies);
}
/**
* Get all plural forms
*/
getPluralForms() {
return Object.values(this.taxonomies);
}
/**
* Setup taxonomy views
*/
setupViews() {
this.views = setupTaxonomyViews(this.taxonomies);
this.viewsByTreeKey = {};
for (const view of this.views) {
this.viewsByTreeKey[view.pluralTreeKey] = view;
}
}
/**
* Get view count
*/
getViewCount() {
return this.views.length;
}
/**
* Check if taxonomies are empty
*/
isEmpty() {
return Object.keys(this.taxonomies).length === 0;
}
};
}
});
// internal/domain/config/vo/social.ts
function decodeSocialConfig(social) {
const config2 = {
userConfig: {},
platformTemplates: [...DefaultSocialPlatformTemplates]
};
if (social && typeof social === "object") {
for (const [platform, settings] of Object.entries(social)) {
if (settings && typeof settings === "object") {
const socialSettings = settings;
if (socialSettings.link) {
config2.userConfig[platform] = {
link: socialSettings.link
};
}
}
}
}
return config2;
}
function getSocialPlatformTemplate(id) {
return DefaultSocialPlatformTemplates.find((template) => template.id === id);
}
var DefaultSocialPlatformTemplates;
var init_social = __esm({
"internal/domain/config/vo/social.ts"() {
"use strict";
DefaultSocialPlatformTemplates = [
{
id: "email",
title: "Email me"
},
{
id: "facebook",
title: "Facebook"
},
{
id: "github",
title: "GitHub"
},
{
id: "gitlab",
title: "GitLab"
},
{
id: "bitbucket",
title: "Bitbucket"
},
{
id: "twitter",
title: "Twitter"
},
{
id: "slack",
title: "Slack"
},
{
id: "reddit",
title: "Reddit"
},
{
id: "linkedin",
title: "LinkedIn"
},
{
id: "xing",
title: "Xing"
},
{
id: "stackoverflow",
title: "StackOverflow"
},
{
id: "snapchat",
title: "Snapchat"
},
{
id: "instagram",
title: "Instagram"
},
{
id: "youtube",
title: "Youtube"
},
{
id: "soundcloud",
title: "SoundCloud"
},
{
id: "spotify",
title: "Spotify"
},
{
id: "bandcamp",
title: "Bandcamp"
},
{
id: "itchio",
title: "Itch.io"
},
{
id: "keybase",
title: "Keybase"
},
{
id: "vk",
title: "VK"
},
{
id: "paypal",
title: "PayPal"
},
{
id: "telegram",
title: "Telegram"
},
{
id: "500px",
title: "500px"
},
{
id: "codepen",
title: "CodePen"
},
{
id: "kaggle",
title: "kaggle"
},
{
id: "mastodon",
title: "Mastodon"
},
{
id: "weibo",
title: "Weibo"
},
{
id: "medium",
title: "Medium"
},
{
id: "discord",
title: "Discord"
},
{
id: "strava",
title: "Strava"
},
{
id: "steam",
title: "Steam"
},
{
id: "quora",
title: "Quora"
},
{
id: "amazonwishlist",
title: "Amazon Wishlist"
},
{
id: "slideshare",
title: "Slideshare"
},
{
id: "angellist",
title: "AngelList"
},
{
id: "about",
title: "About"
},
{
id: "lastfm",
title: "Last.fm"
},
{
id: "bluesky",
title: "Bluesky"
},
{
id: "goodreads",
title: "Goodreads"
}
];
}
});
// internal/domain/config/entity/social.ts
function newSocial(data) {
const socialConfig = decodeSocialConfig(data);
return new Social(socialConfig);
}
var Social;
var init_social2 = __esm({
"internal/domain/config/entity/social.ts"() {
"use strict";
init_social();
Social = class {
socialConfig;
constructor(socialConfig) {
this.socialConfig = socialConfig;
}
/**
* Get user social configuration
*/
getUserConfig() {
return this.socialConfig.userConfig;
}
/**
* Get all available social platform templates
*/
getPlatformTemplates() {
return this.socialConfig.platformTemplates;
}
/**
* Get social platform template by platform ID
*/
getPlatformTemplate(platformId) {
return getSocialPlatformTemplate(platformId);
}
/**
* Check if a social platform is configured by user
*/
isPlatformConfigured(platformId) {
return platformId in this.socialConfig.userConfig;
}
/**
* Get configured social platforms
*/
getConfiguredPlatforms() {
return Object.keys(this.socialConfig.userConfig);
}
/**
* Get processed social links ready for template rendering
* This combines user configuration with icon templates
*/
getProcessedSocialLinks() {
const links = [];
for (const [platformId, userConfig] of Object.entries(this.socialConfig.userConfig)) {
const template = this.getPlatformTemplate(platformId);
if (!template) {
links.push({
id: platformId,
title: platformId.charAt(0).toUpperCase() + platformId.slice(1),
url: userConfig.link
});
continue;
}
links.push({
id: platformId,
title: template.title,
url: userConfig.link
});
}
return links;
}
/**
* Get social link for a specific platform
*/
getSocialLink(platformId) {
const userConfig = this.socialConfig.userConfig[platformId];
if (!userConfig) {
return void 0;
}
const template = this.getPlatformTemplate(platformId);
if (!template) {
return {
id: platformId,
title: platformId.charAt(0).toUpperCase() + platformId.slice(1),
url: userConfig.link
};
}
return {
id: platformId,
title: template.title,
url: userConfig.link
};
}
/**
* Check if any social platforms are configured
*/
hasSocialLinks() {
return Object.keys(this.socialConfig.userConfig).length > 0;
}
/**
* Get the number of configured social platforms
*/
getSocialLinkCount() {
return Object.keys(this.socialConfig.userConfig).length;
}
/**
* Get available social platforms (from templates)
*/
getAvailablePlatforms() {
return this.socialConfig.platformTemplates.map((template) => template.id);
}
/**
* Get social configuration
*/
getSocialConfig() {
return this.socialConfig;
}
};
}
});
// internal/domain/config/vo/markdown.ts
f