LouisBarranqueiro / hexo-theme-tranquilpeak

:lipstick: A gorgeous responsive theme for Hexo blog framework
https://louisbarranqueiro.github.io/hexo-theme-tranquilpeak/
GNU General Public License v3.0
1.86k stars 484 forks source link

Cannot read property 'icon' of null #190

Closed jahbini closed 8 years ago

jahbini commented 8 years ago

I have been having trouble with the image tags described in your theme's docs. I finally realized these extended tags were not in the version I first downloaded (v1.2.0), and downloaded both the hexo-theme-tranquilpeak-built-for-production-1.5.0 and hexo-theme-tranquilpeak-built-for-production-1.6.0

Then (after adding my info to _config.yml in the tranquilpeak directory), I find that 1.5.0 throws an error when it tries to process an {% alert ... %} tag. Version 1.6.0 throws a completely different error:

INFO  Generated: assets/css/jquery.fancybox.css
INFO  Generated: assets/css/jquery.fancybox-thumbs.css
INFO  Generated: assets/css/font-awesome.css
Unhandled rejection TypeError: /Users/jim/Documents/bamboo-snow/themes/tranquilpeak/layout/layout.ejs:18
    16|     <body>
    17|         <div id="blog">
 >> 18|             <%- partial('_partial/header', {sidebarBehavior: sidebarBehavior}) %>
    19|             <%- partial('_partial/sidebar', {sidebarBehavior: sidebarBehavior}) %>
    20|             <%- partial('_partial/post/header-cover', {post: page, sidebarBehavior: sidebarBehavior}) %>
    21|             <div id="main" data-behavior="<%= sidebarBehavior %>"

/Users/jim/Documents/bamboo-snow/themes/tranquilpeak/layout/_partial/header.ejs:3
    1| <!-- Define author's picture -->
    2| <% var authorPicture = null; %>
 >> 3| <% if (!theme.header.right_link.icon) { %>
    4|     <% if (theme.gravatar_email && theme.gravatar_email.length) { %>
    5|         <% authorPicture = gravatar(theme.gravatar_email, 90); %>
    6|     <% } else if (theme.author.picture && theme.author.picture.length) { %>

Cannot read property 'icon' of null
    at eval (eval at <anonymous> (/Users/jim/Documents/bamboo-snow/node_modules/hexo-renderer-ejs/node_modules/ejs/lib/ejs.js:242:14), <anonymous>:30:157)
    at eval (eval at <anonymous> (/Users/jim/Documents/bamboo-snow/node_modules/hexo-renderer-ejs/node_modules/ejs/lib/ejs.js:242:14), <anonymous>:30:3248)

Any suggestions are greatly appreciated.

LouisBarranqueiro commented 8 years ago

Alert tag is a new feature added in version 1.6.0.

Concerning icon problem, could you add your theme configuration file _config.yml, please

jahbini commented 8 years ago

Here is the config file I am currently using _config.yml

I also tried this one which worked with tranquil peak V1.2: config.yml

Both die at the same place during hexo generate

LouisBarranqueiro commented 8 years ago

yeah, that's a bug, i'm gonna fix this. It not allowed to comment header.right_link.icon var. i'm gonna fix this. Give me 20 minutes, to release a patch :)

LouisBarranqueiro commented 8 years ago

In fact, what do you wanna to do? why did you comment these lines instead of remove value?

jahbini commented 8 years ago

I am not sure I commented out any lines. The last couple of days have ben a flurry of bug finding and syntax blinding opportunities.

LouisBarranqueiro commented 8 years ago

It doesn't work because you comment some lines

header:
    right_link:
        # url:
        # icon:
        # class:

Default config :

header:
    right_link:
        url:
        icon:
        class:

uncomment these lines, and it will work

Each configuration file is unique and you can't use configuration file from Tranquilpeak v1.2.0 with Tranquilpeak v1.6.0

jahbini commented 8 years ago

I started with V 1.2.0 which had those items commented out. I did not change them when I moved them from 1.2.0 to 1.5.0 and 1.6.0. (and if you have suggestions for what I should put here, I am your student)

-- this is the original text from that download:

# Header configuration
# The link at the right of the header is customizable
# You can add a link (as an icon) at the right of the header instead of the author's gravatar image or author's picture.
# DON'T edit `header`, `right_link`, `url`, `icon` and `class` variable name
header:
    right_link:
        # url: /#search
        # icon: search
        # class: st-search-show-outputs
LouisBarranqueiro commented 8 years ago

Use the last configuration file from tranquilpeak 1.6.0, and re-set your property, that's all :)

jahbini commented 8 years ago

Yes, I can proceed now. Unfortunate that I started out with 1.2 (I have no idea where that download link came from -- it certainly was not my intention to use an early version -- I just found about tranquipeak 4 or 5 days ago)

Maybe a major version bump if many interface semantics have changed. Yes?

(And yes, this is a fabulous theme you have created: Bravissimo. Ciao for now. )

LouisBarranqueiro commented 8 years ago

hum, I know where does the problem came from. Some days ago, i renamed the repository and the demo website was displayed with version 1.2 with link to download 1.2 version, that's why, you downloaded version 1.2. I contacted GitHub 3 days ago to remove the old site. It has been deleted yesterday.

Thank you man :)