How to enable Grunticon 'data-grunticon-embed' to work

I am having problems with data-grunticon-embed from grunticon. https://github.com/filamentgroup/grunticon

I tried to run it locally and on my web server and nothing seems to work like Chrome or Safari.

My Gruntfile.js

module.exports = function(grunt) {
    // Project configuration.
    grunt.initConfig({
        grunticon: {
            myIcons: {
                    files: [{
                        expand: true,
                        cwd: 'grunt/svgs',
                        src: ['*.svg', '*.png'],
                        dest: "grunt/output"
                    }],
                options: {
                    loadersnippet: "grunticon.loader.js",
                    enhanceSVG: true,
                }
            }
        }
    });
    grunt.loadNpmTasks('grunt-grunticon');
    grunt.registerTask('default', ['grunticon:myIcons']);
};

      

In my title, I have

<script>
/* grunticon Stylesheet Loader | https://github.com/filamentgroup/grunticon | (c) 2012 Scott Jehl, Filament Group, Inc. | MIT license. */
        window.grunticon=function(e){if(e&&3===e.length){var t=window,n=!(!t.document.createElementNS||!t.document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect||!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1")||window.opera&&-1===navigator.userAgent.indexOf("Chrome")),o=function(o){var r=t.document.createElement("link"),a=t.document.getElementsByTagName("script")[0];r.rel="stylesheet",r.href=e[o&&n?0:o?1:2],a.parentNode.insertBefore(r,a)},r=new t.Image;r.onerror=function(){o(!1)},r.onload=function(){o(1===r.width&&1===r.height)},r.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="}};
        grunticon(["<?php echo get_template_directory_uri(); ?>/grunt/output/icons.data.svg.css", "<?php echo get_template_directory_uri(); ?>/grunt/output/icons.data.png.css", "<?php echo get_template_directory_uri(); ?>/grunt/output/icons.fallback.css"], grunticon.svgLoadedCallback );
        </script>
<noscript><link href="<?php echo get_template_directory_uri(); ?>/grunt/output/icons.fallback.css" rel="stylesheet"></noscript>

      

and in my page i use this, the icon is displayed ok but not embedded in the svg data.

<div class="icon-twitter" style="width: 50px; height: 50px; background-size:50%;" data-grunticon-embed></div></a>


UPDATE:

There is still no joy. Now I have it working on my server http://benjgorman.com/ the icons in the footer / nav are svg. I can tell the browser is receiving the SVG data as I can see it in the console, but it is not embedded in the page so it is not styled.

Console information

Inspect item on one icon

+3


source to share


1 answer


It turns out that following an outdated tutorial I was using the wrong version of Grunticon. My package.json now looks like this, which is what I needed to change. After that everything works fine.



{
    "name": "my-grunticon-test",
    "version": "0.1.0",
    "dependencies": {
        "grunt": "~0.4.4",
        "grunt-grunticon": "~2.2.1"

    }
}

      

+1


source







All Articles