Search code examples
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.