Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • How do I embed a single file from a GitHub gist with the new gist interface?
  • Yes, we get the gist

Thanks, M.

like image 520
Mathieu Nls Avatar asked Nov 25 '16 16:11

Mathieu Nls


People also ask

Can a GIST have multiple files?

We've always had the ability to embed multiple file gists: Your browser does not support IFrames But today we added the ability to embed specific files in a multi-file gist!… But today we added the ability to embed specific files in a multi-file gist! Enjoy!

How do I add files to gist?

Go to your Gist and click the Edit button at the top right. The Gist editor will show your files in edit mode, then look at the bottom left and there you will find an 'Add file' button. Click it and the cursor will be moved to the 'File name box..', type a name and click the 'Update gist' button at the bottom right.


1 Answers

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.

like image 54
Mojtaba Hosseini Avatar answered Oct 03 '22 12:10

Mojtaba Hosseini