From 6a93d3d7c3c3e61339bde84c30056cad08f21e6c Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 07 Jul 2022 17:00:52 +0800
Subject: [PATCH] fix template static path

---
 src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java b/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java
index 27d74e6..c85e75e 100644
--- a/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java
+++ b/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java
@@ -7,6 +7,7 @@
 import com.xcong.farmer.cms.core.handler.DataParserHandler;
 import com.xcong.farmer.cms.core.tag.TagsEnum;
 import com.xcong.farmer.cms.core.template.Configuration;
+import com.xcong.farmer.cms.core.template.TemplateConfiguration;
 import groovy.lang.Binding;
 import groovy.lang.GroovyShell;
 import org.apache.commons.text.StringSubstitutor;
@@ -79,17 +80,30 @@
                 this.element.attr("src", STATIC_URL + src);
             }
         }
+
+        if ("link".equals(this.element.tagName())) {
+            String src = this.element.attr("href");
+            if (StrUtil.isNotBlank(STATIC_URL)) {
+                this.element.attr("href", STATIC_URL + src);
+            }
+        }
+
+        if ("script".equals(this.element.tagName())) {
+            String src = this.element.attr("src");
+            if (StrUtil.isNotBlank(STATIC_URL)) {
+                this.element.attr("src", STATIC_URL + src);
+            }
+        }
     }
 
     public void parser() {
+        staticPath();
         // 判断是否为最小节点,如果是且没有特殊标签,则跳过清空
         if (!isNeedEmpty()) {
             return;
         }
 
         this.element.empty();
-
-        staticPath();
         Attributes attributes = this.element.attributes();
         if (attributes.isEmpty()) {
             return;

--
Gitblit v1.9.1