hexo-theme-yilia icon indicating copy to clipboard operation
hexo-theme-yilia copied to clipboard

hexo g的时候出现错误!

Open imydl opened this issue 6 years ago • 3 comments

TypeError: /home/wwwroot/hexo.imydl.tech/themes/yilia/layout/page.ejs:1
 >> 1| <%- partial('_partial/article', {post: page, index: false}) %>

/home/wwwroot/hexo.imydl.tech/themes/yilia/layout/_partial/article.ejs:61
    59|         </div>
    60|       <% } %>
 >> 61|       <%- partial('post/tag') %>
    62|       <%- partial('post/category') %>
    63|       <% if (index && theme.show_all_link){ %>
    64|         <p class="article-more-link">

/home/wwwroot/hexo.imydl.tech/themes/yilia/layout/_partial/post/tag.ejs:7
    5| 			<% post.tags.forEach(function(tag, i){ %> 
    6|         		<li class="article-tag-list-item">
 >> 7|         			<a href="javascript:void(0)" class="js-tag article-tag-list-link color<%= tag.name.length % 5 + 1 %>"><%-tag.name%></a>
    8|         		</li>
    9|       		<% }) %>
    10| 		</ul>

Cannot read property 'length' of undefined

imydl avatar Apr 17 '18 15:04 imydl

遇到了同样的问题,请问答主解决了嘛QAQ?跪求解决方案!


Update: 已解决.

./themes/yilia/layout/_partial/post/category.ejs改为:

<% if (post.categories && post.categories.length){ %>
<div class="article-category tagcloud">
	<i class="icon-book icon"></i>
	<ul class="article-tag-list">
		<% post.categories.forEach(function(tag, i){ %>
		<% if (tag.hasOwnProperty('name')){ %>
		<li class="article-tag-list-item">
			<a href="<%= config.root %><%= tag.path %>/" class="article-tag-list-link color<%= tag.name.length % 5 + 1 %>">
				<%-tag.name%></a>
		</li>
		<% } %>
		<% }) %>
	</ul>
</div>
<% } %>

./themes/yilia/layout/_partial/post/tag.ejs改为:

<% if (post.tags && post.tags.length){ %>
<div class="article-tag tagcloud">
	<i class="icon-price-tags icon"></i>
	<ul class="article-tag-list">
		<% post.tags.forEach(function(tag, i){ %>
		<% if (tag.hasOwnProperty('name')){ %>
		<li class="article-tag-list-item">
			<a href="javascript:void(0)" class="js-tag article-tag-list-link color<%= tag.name.length % 5 + 1 %>">
				<%-tag.name%></a>
		</li>
		<% } %>
		<% }) %>
	</ul>
</div>
<% } %>

Update at Nov 13, 2021: 感谢 @white-loub 指出错误,已修复qwq

namasikanam avatar Dec 19 '18 07:12 namasikanam

已解决.

好像还是不行哦

Sunxb avatar Apr 29 '19 02:04 Sunxb

@namasikanam 的解决方案的第二个文件修改的地方少了一个 if

white-loub avatar Nov 13 '21 13:11 white-loub