Easy SVG Icons with Edge Iconify

In this lesson, we'll learn how we can install and use the edge-iconify package giving us super easy access within our EdgeJS files to any of the SVG icon packages available through Iconify.

Published
Feb 21
Duration
7m 57s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.

Adocasts

Burlington, KY

Join The Discussion! (4 Comments)

Please sign in or sign up for free to join in on the dicussion.

  1. Commented 1 month ago

    Hi Tom, really enjoying the videos. I have a question on this one. As per the documentation I'm using in globals.ts

    import { Edge } from 'edge.js'
    import { edgeIconify, addCollection } from 'edge-iconify'
    import { icons as heroIcons } from '@iconify-json/heroicons'
    
    addCollection(heroIcons)
    
    const edge = Edge.create()
    
    edge.use(edgeIconify)
    
    Copied!

    And then in my home.edge I'm using @svg('heroicons:arrow-left-solid') but I just get raw tag rendered rather than the svg icon. Any ideas?

    Copied!

    1

    Please sign in or sign up for free to reply

    1. Commented 1 month ago

      Hey cbernard! Thank you, I'm happy to hear that! Yeah, so the EdgeJS documentation takes a framework-agnostic approach to describing things. Within AdonisJS, the edge instance has already been created and you'll want to reference the already existing instance when adding your icons.

      Small change, but this should get things working for ya:

      import edge from 'edge.js' // <-- import default export as edge instance
      import { edgeIconify, addCollection } from 'edge-iconify'
      import { icons as heroIcons } from '@iconify-json/heroicons'
      
      addCollection(heroIcons)
      
      edge.use(edgeIconify) // <-- add to that pre-existing instance
      Copied!
      0

      Please sign in or sign up for free to reply

      1. Commented 1 month ago

        Thanks Tom for the speedy reply. I had originally tried that but to no avail. However, I found my issue. It was because the globals.ts was not registered with the preloads in adonisrc.ts. I think that is explained in lesson 3.8, but I must have missed it.

        1

        Please sign in or sign up for free to reply

        1. Commented 1 month ago

          Anytime! Ah - yes, preloads need registered within the preloads array inside the adonisrc.ts file to be used; happy you were able to get your issue figured out!

          If you create your preload file using the Ace CLI's node ace make:preload command, it'll automatically register it within the preloads array for you as well.

          1

          Please sign in or sign up for free to reply

Playing Next Lesson In
seconds