100100 let publishSuccess = false ;
101101 let publishUrl = ' ' ;
102102 // Map 'mdfriday' from settings to 'netlify' as default (settings uses 'mdfriday' for display config)
103- let selectedPublishOption: ' netlify' | ' ftp' | ' mdf-share' | ' mdf-app' | ' mdf-custom' =
103+ let selectedPublishOption: ' netlify' | ' ftp' | ' mdf-share' | ' mdf-app' | ' mdf-custom' | ' mdf-enterprise ' =
104104 (plugin .settings .publishMethod === ' mdfriday' ? ' netlify' : plugin .settings .publishMethod ) || ' netlify' ;
105105
106106 // Netlify configuration (project-specific)
@@ -133,6 +133,7 @@ let selectedPublishOption: 'netlify' | 'ftp' | 'mdf-share' | 'mdf-app' | 'mdf-cu
133133 let hasPublishPermission = false ;
134134 let hasSubdomainPermission = false ;
135135 let hasCustomDomainPermission = false ;
136+ let hasEnterprisePermission = false ;
136137 let publishOptions: Array <{ value: string ; label: string }> = [];
137138
138139 // Reactive block to update license-related state (similar to theme selection at line 64-79)
@@ -145,28 +146,33 @@ let selectedPublishOption: 'netlify' | 'ftp' | 'mdf-share' | 'mdf-app' | 'mdf-cu
145146
146147 // Check feature permissions from license
147148 const features = plugin .settings .license ?.features ;
149+ const licenseplan = plugin .settings .license ?.plan ;
148150 hasPublishPermission = isLicenseActivated && features ?.publish_enabled === true ;
149151 hasSubdomainPermission = isLicenseActivated && features ?.custom_sub_domain === true ;
150152 hasCustomDomainPermission = isLicenseActivated && features ?.custom_domain === true ;
153+ hasEnterprisePermission = isLicenseActivated && licenseplan === ' enterprise' && !! plugin .settings .enterpriseServerUrl ;
151154
152- // Update publish options - MDFriday Share, MDFriday Subdomain, and MDFriday Custom Domain are always shown
155+ // Update publish options - MDFriday Share, MDFriday Subdomain, MDFriday Custom Domain, and MDFriday Enterprise are always shown
153156 publishOptions = [
154157 { value: ' netlify' , label: t (' ui.publish_option_netlify' ) },
155158 { value: ' ftp' , label: t (' ui.publish_option_ftp' ) },
156159 { value: ' mdf-share' , label: t (' ui.publish_option_mdfriday_share' ) },
157160 { value: ' mdf-app' , label: t (' ui.publish_option_mdfriday_app' ) },
158161 { value: ' mdf-custom' , label: t (' ui.publish_option_mdfriday_custom' ) },
162+ { value: ' mdf-enterprise' , label: t (' ui.publish_option_mdfriday_enterprise' ) },
159163 ];
160164 }
161165
162166 // Check if current publish option requires license and permissions
163167 $ : requiresPublishPermission = selectedPublishOption === ' mdf-share' ;
164168 $ : requiresSubdomainPermission = selectedPublishOption === ' mdf-app' ;
165169 $ : requiresCustomDomainPermission = selectedPublishOption === ' mdf-custom' ;
170+ $ : requiresEnterprisePermission = selectedPublishOption === ' mdf-enterprise' ;
166171 $ : isPublishDisabled =
167172 (requiresPublishPermission && ! hasPublishPermission ) ||
168173 (requiresSubdomainPermission && ! hasSubdomainPermission ) ||
169- (requiresCustomDomainPermission && ! hasCustomDomainPermission );
174+ (requiresCustomDomainPermission && ! hasCustomDomainPermission ) ||
175+ (requiresEnterprisePermission && ! hasEnterprisePermission );
170176
171177 // HTTP server related
172178 let httpServer: IncrementalBuildCoordinator ;
@@ -1236,7 +1242,8 @@ let selectedPublishOption: 'netlify' | 'ftp' | 'mdf-share' | 'mdf-app' | 'mdf-cu
12361242 publishProgress = 80 ;
12371243
12381244 // Step 3: Deploy the preview (80-100%)
1239- const deployPath = await plugin .hugoverse .deployMDFridayPreview (previewApiId );
1245+ const licenseKey = plugin .settings .license ?.key || ' ' ;
1246+ const deployPath = await plugin .hugoverse .deployMDFridayPreview (previewApiId , licenseKey );
12401247 if (! deployPath ) {
12411248 throw new Error (' Failed to deploy MDFriday preview' );
12421249 }
@@ -1281,7 +1288,8 @@ let selectedPublishOption: 'netlify' | 'ftp' | 'mdf-share' | 'mdf-app' | 'mdf-cu
12811288 publishProgress = 80 ;
12821289
12831290 // Step 3: Deploy the preview (80-100%)
1284- const deployPath = await plugin .hugoverse .deployMDFridayPreview (previewApiId );
1291+ const licenseKey = plugin .settings .license ?.key || ' ' ;
1292+ const deployPath = await plugin .hugoverse .deployMDFridayPreview (previewApiId , licenseKey );
12851293 if (! deployPath ) {
12861294 throw new Error (' Failed to deploy MDFriday Subdomain' );
12871295 }
@@ -1330,7 +1338,8 @@ let selectedPublishOption: 'netlify' | 'ftp' | 'mdf-share' | 'mdf-app' | 'mdf-cu
13301338 publishProgress = 80 ;
13311339
13321340 // Step 3: Deploy the preview (80-100%)
1333- const deployPath = await plugin .hugoverse .deployMDFridayPreview (previewApiId );
1341+ const licenseKey = plugin .settings .license ?.key || ' ' ;
1342+ const deployPath = await plugin .hugoverse .deployMDFridayPreview (previewApiId , licenseKey );
13341343 if (! deployPath ) {
13351344 throw new Error (' Failed to deploy MDFriday Custom Domain' );
13361345 }
@@ -1369,6 +1378,64 @@ let selectedPublishOption: 'netlify' | 'ftp' | 'mdf-share' | 'mdf-app' | 'mdf-cu
13691378 plugin .hugoverse .sendCounter (' mdf-custom' ).catch (error => {
13701379 console .warn (' Counter request failed (non-critical):' , error );
13711380 });
1381+ } else if (selectedPublishOption === ' mdf-enterprise' ) {
1382+ // MDFriday Enterprise deployment
1383+ const zipContent = await createZipFromDirectory (publicDir );
1384+ publishProgress = 50 ;
1385+
1386+ // MDFriday Enterprise uses sitePath as name and type 'enterprise'
1387+ const previewApiId = await plugin .hugoverse .createMDFPreview (previewId , zipContent , ' enterprise' , sitePath );
1388+ if (! previewApiId ) {
1389+ throw new Error (' Failed to create MDFriday Enterprise preview' );
1390+ }
1391+ publishProgress = 80 ;
1392+
1393+ // Step 3: Deploy the preview (80-100%) with license key
1394+ const licenseKey = plugin .settings .license ?.key || ' ' ;
1395+ const deployPath = await plugin .hugoverse .deployMDFridayPreview (previewApiId , licenseKey );
1396+ if (! deployPath ) {
1397+ throw new Error (' Failed to deploy MDFriday Enterprise' );
1398+ }
1399+ publishProgress = 100 ;
1400+
1401+ // Step 4: Construct final publish URL for MDFriday Enterprise
1402+ // Use enterprise server URL from settings
1403+ const enterpriseServerUrl = plugin .settings .enterpriseServerUrl ;
1404+ if (! enterpriseServerUrl ) {
1405+ throw new Error (' Enterprise server URL not configured' );
1406+ }
1407+ // Extract main domain from URL (e.g., mdfriday.sunwei.xyz -> sunwei.xyz)
1408+ const fullHost = enterpriseServerUrl .replace (/ ^ https? :\/\/ / , ' ' ).replace (/ \/ $ / , ' ' );
1409+ const hostParts = fullHost .split (' .' );
1410+ // Get last 2 parts (domain.tld), e.g., sunwei.xyz
1411+ const host = hostParts .length >= 2 ? hostParts .slice (- 2 ).join (' .' ) : fullHost ;
1412+ const basePath = deployPath .startsWith (' /' ) ? deployPath : ` /${deployPath } ` ;
1413+ const normalizedPath = basePath === ' /' ? ' ' : basePath ;
1414+ publishUrl = ` https://${host }${normalizedPath } ` ;
1415+ publishSuccess = true ;
1416+
1417+ new Notice (t (' messages.site_published_successfully' ), 3000 );
1418+
1419+ // Save project configuration and add build history
1420+ await saveCurrentProjectConfiguration ();
1421+ if (currentContents .length > 0 && siteName ) {
1422+ const projectId = getProjectId ();
1423+ if (projectId ) {
1424+ await plugin .projectService .addBuildHistory ({
1425+ projectId: projectId ,
1426+ timestamp: Date .now (),
1427+ success: true ,
1428+ type: ' publish' ,
1429+ publishMethod: ' mdf-enterprise' ,
1430+ url: publishUrl
1431+ });
1432+ }
1433+ }
1434+
1435+ // Send counter for publish (don't wait for result)
1436+ plugin .hugoverse .sendCounter (' mdf-enterprise' ).catch (error => {
1437+ console .warn (' Counter request failed (non-critical):' , error );
1438+ });
13721439 }
13731440
13741441 } catch (error ) {
@@ -2629,6 +2696,20 @@ let selectedPublishOption: 'netlify' | 'ftp' | 'mdf-share' | 'mdf-app' | 'mdf-cu
26292696 </div >
26302697 {/if }
26312698
2699+ <!-- MDFriday Enterprise Info -->
2700+ {#if selectedPublishOption === ' mdf-enterprise' }
2701+ <div class =" publish-config" >
2702+ <div class =" field-hint" >
2703+ {t (' ui.mdfriday_enterprise_hint' )}
2704+ </div >
2705+ {#if ! hasEnterprisePermission }
2706+ <div class =" license-warning" >
2707+ ⚠️ {t (' settings.upgrade_for_enterprise' )}
2708+ </div >
2709+ {/if }
2710+ </div >
2711+ {/if }
2712+
26322713 <!-- Publish Button -->
26332714 <div class =" publish-actions" >
26342715 {#if isPublishing }
0 commit comments