GithubHelp home page GithubHelp logo

Comments (3)

lh1me avatar lh1me commented on August 17, 2024 2

#34

首先谢谢你参与到主题的开发中。

关于主题配置的形式,我是在 这次commit 改成全局的,主要目的一是尽量统一一份配置文件,二是通过简化配置从而简化自动化构建流程。加前缀标示可以用于区分配置。

在项目早期我决定处理的配置问题,是为了避免后期使用者更新需要更新大量配置。在确定了项目配置形式的情况下,修改配置结构是破坏性操作,我不建议这么做。

你提交了两个 commit,我这边的建议是,保留 fix back archive.ejs theme.archive_dir back to config.archive_dir

from hexo-theme-aomori.

lh1me avatar lh1me commented on August 17, 2024 1

哈哈,其实感觉你前期的那个想法更加好。想一下,如果一个博客允许切换主题,切换到了其他主题,如果采用了全局的config其实就会多了些对于另外主题没有用的变量了。
另外一个问题就是,你修改为全局的时候没有给默认值,后面模板渲染没有判断config.aomori_widgets,会出现Cannot read property 'forEach' of undefined的错误
image
https://github.com/lh1me/hexo-theme-aomori/blob/master/layout/_partial/sidebar.ejs

<% if (config.aomori_search_algolia){ %>
    <%- partial('_partial/search') %>
<% } %>

<div class="widget" id="widget">
    <% config.aomori_widgets.forEach(function(widget){ %>
      <%- partial('_widget/' + widget) %>
    <% }) %>
</div>

<div id="backtop"><i class="icon icon-arrow-up"></i></div>

全局变量的存在因为加了前缀区分不会存在污染问题,全局变量是提供给 Hexo 编译的,所以对另外的主题来说其实并没有 没有用的变量 这个说法。

关于默认值这个问题确实是个问题,没有给默认值在编译阶段直接报错其实是可以接受的,当然如果考虑用户使用友好,是需要做大量的兼容性判断的。我会在之后考虑一下这个问题,也参考一下别人的做法。

from hexo-theme-aomori.

Cendeal avatar Cendeal commented on August 17, 2024

哈哈,其实感觉你前期的那个想法更加好。想一下,如果一个博客允许切换主题,切换到了其他主题,如果采用了全局的config其实就会多了些对于另外主题没有用的变量了。
另外一个问题就是,你修改为全局的时候没有给默认值,后面模板渲染没有判断config.aomori_widgets,会出现Cannot read property 'forEach' of undefined的错误
image
https://github.com/lh1me/hexo-theme-aomori/blob/master/layout/_partial/sidebar.ejs

<% if (config.aomori_search_algolia){ %>
    <%- partial('_partial/search') %>
<% } %>

<div class="widget" id="widget">
    <% config.aomori_widgets.forEach(function(widget){ %>
      <%- partial('_widget/' + widget) %>
    <% }) %>
</div>

<div id="backtop"><i class="icon icon-arrow-up"></i></div>

from hexo-theme-aomori.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.