This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pbCopy = (text) => { | |
const tmp = document.createElement('div'); | |
const pre = document.createElement('pre'); | |
pre.style.webkitUserSelect = 'auto'; | |
pre.style.userSelect = 'auto'; | |
tmp.style.position = 'fixed'; | |
tmp.style.right = '200%'; | |
tmp.appendChild(pre).textContent = text; | |
document.body.appendChild(tmp); | |
document.getSelection().selectAllChildren(tmp); |
Problem: When linking to the raw version of a gist, the link changes with each revision.
Solution:
To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/
- Example: https://gist.github.com/atenni/5604522/raw/
- Works even when you change the filename.
To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]