hexojs / hexo-fontawesome

A utility function which helps to inline fontawesome SVG files.
MIT License
16 stars 7 forks source link

Use FA Icons in Posts #1

Closed tohuw closed 6 years ago

tohuw commented 6 years ago

Forgive me if this is a question I might have solved by reading the Hexo docs, but is there some way to use this and show an icon in a post as well?

ertrzyiks commented 6 years ago

If you are a developer you can create a blog-specific tag plugin using the provided helper https://hexo.io/api/tag.html

It actually should be provided out of box for non-technical users indeed. I put your feature request on my to-do list. Give me a day or two.

sob., 19 maj 2018, 10:29 użytkownik Ron Scott-Adams < notifications@github.com> napisał:

Forgive me if this is a question I might have solved by reading the Hexo docs, but is there some way to use this and show an icon in a post as well?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hexojs/hexo-fontawesome/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/ACUzUd2qELrRWuZKUOeMrkHonWLMqtc-ks5tz9fzgaJpZM4UFoOn .

ertrzyiks commented 6 years ago

Hey @tohuw , I've just released v1.1.0 with the functionality you need.

{% fa_inline twitter %}

(plus on the very end of the post)
{% fa_css %}

The CSS is needed to provide default dimensions. You can omit it and use only fa_inline tag, but then you need to change the size, color etc of the image yourself.

Please let me know if it works for you.

tohuw commented 6 years ago

Wow, thanks so much for the quick response! Unfortunately, when I tried it on a post using the default landscape theme, I get the following:

INFO  Start processing
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Template render error: TypeError: Cannot read property 'html' of undefined
    at Object._prettifyError (/home/tohuw/Projects/hexo-tohuwnet/node_modules/nunjucks/src/lib.js:35:11)
    at /home/tohuw/Projects/hexo-tohuwnet/node_modules/nunjucks/src/environment.js:547:19
    at Template.root [as rootRenderFunc] (eval at _compile (/home/tohuw/Projects/hexo-tohuwnet/node_modules/nunjucks/src/environment.js:617:18), <anonymous>:18:3)
    at Template.render (/home/tohuw/Projects/hexo-tohuwnet/node_modules/nunjucks/src/environment.js:540:10)
    at Environment.renderString (/home/tohuw/Projects/hexo-tohuwnet/node_modules/nunjucks/src/environment.js:364:17)
    at Promise (/home/tohuw/Projects/hexo-tohuwnet/node_modules/hexo/lib/extend/tag.js:66:9)
    at Promise._execute (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/debuggability.js:303:9)
    at Promise._resolveFromExecutor (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/promise.js:483:18)
    at new Promise (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/promise.js:79:10)
    at Tag.render (/home/tohuw/Projects/hexo-tohuwnet/node_modules/hexo/lib/extend/tag.js:64:10)
    at Object.tagFilter [as onRenderEnd] (/home/tohuw/Projects/hexo-tohuwnet/node_modules/hexo/lib/hexo/post.js:230:16)
    at Promise.then.then.result (/home/tohuw/Projects/hexo-tohuwnet/node_modules/hexo/lib/hexo/render.js:65:19)
    at tryCatcher (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/tohuw/Projects/hexo-tohuwnet/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)

The error only occurs once I drop the above tags into a test post.

tohuw commented 6 years ago

Ah, got it, thanks to your README. I was using {% fa_inline twitter %}, but should have used {% fa_inline twitter fab %}. Thanks, this is great!

ertrzyiks commented 6 years ago

@tohuw ah, error reporting is poor here indeed. I will improve it soon-ish as it's a common defect for both the theme and the post use case. I've created #3 to keep track on it