店匠Nova主题根据域名自动切换logo

  1. 在编辑里找到header_logo.liquid
  2. 使用以下代码替换框选整行,并替换域名和img的url,最后一个是都不是这些域名的时候出现的logo,按需配置
    <script language="javascript">
    host2=document.domain; 
    var host2=host2.replace("www.","");
    if (host2=="XXX.com") {
    document.write('<img src="https://XXX.com/XXX.png" data-src="" alt="" class="tw-absolute tw-inset-0 tw-w-full tw-h-full lazyload"/>')
    }else if (host2=="YYY.com") {
    document.write('<img src="https://YYY.com/YYY.png" data-src="" alt="" class="tw-absolute tw-inset-0 tw-w-full tw-h-full lazyload"/>')
    }else
    {
    document.write('<img src="https://ZZZ.com/ZZZ.png" data-src="" alt="" class="tw-absolute tw-inset-0 tw-w-full tw-h-full lazyload"/>')
    }
    </script>
    
  3. 设置一个默认的logo,其他替换logo的尺寸要跟默认logo一致,按需设置logo宽度
本站所有资源收集整理于网络,用于互联网爱好者学习和研究,如不慎侵犯了您的权利,请及时联系站长处理删除。敬请谅解! 侵权删帖/违法举报/投稿等联系邮箱(#替换成@):atticus_beta#outlook.com © 2021 - 2025 Lux. All rights reserved. Powered by Lux.