diff --git a/src/main/java/run/halo/app/event/freemarker/FreemarkerConfigAwareListener.java b/src/main/java/run/halo/app/event/freemarker/FreemarkerConfigAwareListener.java index 003ddf25c..69b855a06 100644 --- a/src/main/java/run/halo/app/event/freemarker/FreemarkerConfigAwareListener.java +++ b/src/main/java/run/halo/app/event/freemarker/FreemarkerConfigAwareListener.java @@ -12,6 +12,7 @@ import run.halo.app.event.options.OptionUpdatedEvent; import run.halo.app.event.theme.ThemeActivatedEvent; import run.halo.app.event.user.UserUpdatedEvent; import run.halo.app.handler.theme.config.support.ThemeProperty; +import run.halo.app.model.properties.OtherProperties; import run.halo.app.model.support.HaloConst; import run.halo.app.service.OptionService; import run.halo.app.service.ThemeService; @@ -98,7 +99,8 @@ public class FreemarkerConfigAwareListener { private void loadThemeConfig() throws TemplateModelException { ThemeProperty activatedTheme = themeService.getActivatedTheme(); configuration.setSharedVariable("theme", activatedTheme); - configuration.setSharedVariable("static", optionService.getBlogBaseUrl() + "/" + activatedTheme.getFolderName()); + String baseUrl = optionService.getByProperty(OtherProperties.CDN_DOMAIN).orElse(optionService.getBlogBaseUrl()).toString(); + configuration.setSharedVariable("static", baseUrl + "/" + activatedTheme.getFolderName()); configuration.setSharedVariable("settings", themeSettingService.listAsMapBy(themeService.getActivatedThemeId())); log.debug("Loaded theme and settings"); } diff --git a/src/main/java/run/halo/app/model/properties/OtherProperties.java b/src/main/java/run/halo/app/model/properties/OtherProperties.java index dc8c295b9..29c382534 100644 --- a/src/main/java/run/halo/app/model/properties/OtherProperties.java +++ b/src/main/java/run/halo/app/model/properties/OtherProperties.java @@ -9,7 +9,9 @@ package run.halo.app.model.properties; */ public enum OtherProperties implements PropertyEnum { - CUSTOM_HEAD("blog_custom_head",String.class,""), + CDN_DOMAIN("blog_cdn_domain", String.class, ""), + + CUSTOM_HEAD("blog_custom_head", String.class, ""), STATISTICS_CODE("blog_statistics_code", String.class, "");