gist

Single file of a multi-files gist on Medium.com


Does anyone know a way to include a single file of a multi-file gist into a medium post?

I've tried, without luck, the solutions proposed here:


Solution

  • 2020 - It is possible! šŸŽŠšŸŽ‰

    There is a way for that without using <script>, but it's kind of tricky:

    āš ļø The order matters!

    1. Copy the (multi-file) gist path. e.g.:
    https://gist.github.com/MojtabaHs/91e34fd0e987fe7ce801936dc6ece0e8
    

    1. Paste it somewhere else than the Medium article. Like an online textbox:

    Demo

    āš ļø Do not hit search or return button


    1. Append the query param for the file to the URL. e.g:
    https://gist.github.com/MojtabaHs/91e34fd0e987fe7ce801936dc6ece0e8?file=Interface.swift
    

    Note that ?file=Interface.swift at the end of the URL, right?


    1. Copy and paste it in the article and see the magic šŸ”®

    An article using this method:

    Implement Custom Activity Indicator With The SwiftUI


    The MOST Important note that MUST be considered:

    āš ļø Note that you MUST copy an unformatted plain text in the medium and MUST NOT edit the URL after pasting it in the Medium! You can copy the link in an online textbox like google.com and after appending the query, copy it back and paste it in the Medium.