@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
58 lines • 2.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.newSite = newSite;
const site_1 = require("../entity/site");
const publisher_1 = require("../entity/publisher");
const url_1 = require("../entity/url");
const ref_1 = require("../entity/ref");
const language_1 = require("../entity/language");
const author_1 = require("../valueobject/author");
const version_1 = require("../valueobject/version");
const navigation_factory_1 = require("./navigation-factory");
const log_1 = require("../../../../pkg/log");
// Create domain-specific logger for site factory operations
const log = (0, log_1.getDomainLogger)('site', { component: 'factory' });
/**
* Create new Site instance with enhanced Navigation (including menu building)
* TypeScript equivalent of New function from Go
*/
function newSite(services) {
// Create Publisher - use type assertion as temporary solution
const publisher = new publisher_1.Publisher(services.publishFs());
// Create URL handler
const url = new url_1.URL(services.baseUrl(), true);
// Create Language handler
const language = new language_1.Language(services);
// Create Navigation with menu building capabilities using the new factory
const navigationFactory = (0, navigation_factory_1.createNavigationFactory)(services, services);
const navigation = navigationFactory.createNavigation();
// Create Author (TODO: Make configurable)
const author = (0, author_1.newAuthor)('MDFriday', 'support@mdfriday.com');
// Create Compiler (TODO: Make configurable)
const compiler = (0, version_1.newVersion)('0.1.0');
// Create Site instance first
const site = new site_1.Site(services, // ConfigService
services, // ContentService
services, // TranslationService
services, // LanguageService
services, // SitemapService
services, // StaticCopyService
publisher, author, compiler, url, {}, // Ref - will be created with site reference
language, navigation, services.siteTitle());
// Create Ref handler with site reference
const ref = new ref_1.Ref({
home: { page: null },
sitePage: async (target) => {
const sitePage = await site.sitePage(target);
// Create a simple SitePage adapter
return {
relPermalink: () => sitePage.path ? sitePage.path() : '',
permalink: () => sitePage.path ? sitePage.path() : ''
};
}
}, services, '/404.html');
// Replace the placeholder ref
site.ref = ref;
return site;
}
//# sourceMappingURL=site.js.map