Code Chewing Guides

PAGE 3 OF 7
  • Add your own custom facebook share button to your website

    There are many third party solutions, that offer ways to quickly embed share menus and widgets into your website. Services such as AddThis, even go as far as providing you with analytics. But all this can be excessive (and may take a hit on your page performance), if all you really want is for users to be able to easily share your article on their chosen social media platform.

    We're basically going to do the facebook part of this:

    Share menu with Facebook button

    If you're interested in creating your own twitter sharer too, check out our twitter share article as well.

    Sample facebook share window

    Read more
  • Add your own custom twitter share button to your website

    There are many third party solutions, that offer ways to quickly embed share menus and widgets into your website. Services such as AddThis, even go as far as providing you with analytics. But all this can be extravagant (and may take a hit on your page performance), if all you really want is for users to be able to easily share your article on their chosen social media platform.

    We're basically going to do the twitter part of this:

    Share menu with Twitter button

    If you're interested in creating your own facebook sharer too, check out our facebook share article as well.

    Sample twitter share window

    Read more
  • Add custom HTML attributes to anchor tag with Showdown extension

    Whilst converting markdown to HTML, using the Showdown JavaScript library, there inevitably comes a moment where the standard syntax falls short of a few additional tricks up its sleeve.

    Once you've hit this proverbial wall, Showdown offers a way to easily extend its converter to fulfill extra requirements. And that's what we're going to explore in this article.

    The standard ways to compose links in markdown

    Here are the inline style links:

    [Example](https://example.org)
    -> <a href="https://example.org">Example</a>
    
    [Example with title](https://example.org "A title")
    -> <a href="https://example.org" title="A title">Example</a>
    
    Read more
  • Recursively read JSON file in directory tree using node.js

    Not exactly a catchy title, but something I wanted to explore myself.

    The scenario is that we want to read the contents of a JSON file (doesn't have to be JSON of course…) in each directory and pluck some information out of it to store some meta data about the directory structure we're walking.

    Let's suppose we have the following directory structure:

    .
    └---food
    │   │   meta.json
    │   │   ...
    │   │
    │   └---sweets
    │   │   │   meta.json
    │   │   │   ...
    │   │   │
    │   │   └---lollipop
    │   │       │   meta.json
    │   │       │   ...
    │   │       
    │   └---vegetables 
    │       │   meta.json
    │       │   ...
    │       │
    │       └---cabbage
    │           │   meta.json
    │           │   ...
    

    You can see that we've got 5 meta.json files at varying depth in the directory structure. Each one contains the following JSON:

    Read more
  • Markdown to HTML via node.js server

    Here's our scenario to embark on:
    You've got some static markdown pages that you wish to convert into HTML. You've decided that you want to perform this markdown to HTML conversion on the fly, so that when that particular URL request is made to your node.js server, it returns not the markdown, but the HTML version instead. Sounds easy, right?

    Let's assume some simple markdown:

    Hello, **world**!
    

    We've applied some bold to "world" using the asterisks.

    Our directory structure is the following:

    Read more
Code Chewing Twitter