Bookmarklet: Copy Ghost Post ID to Clipboard
Save several milliseconds with two lines of JavaScript
I often need to get the internal UUID for a Ghost CMS post: for example, in order to save it as markdown.
Previously, I would go to the post, append /edit to the URL, hit enter, and then copy the last section of the URL, which is the UUID for the post in the editor. Tedious!
As I suspected, the post ID is right there in the HTML of the post: it’s used to load comments for the right post. So, like I did for appending /edit to the URL:
.... and linking to text fragments, and jumping between staging and production versions of a site, I wrote a two-line bookmarklet to extract the current post ID, and put it on the clipboard:
let postId = document.querySelector("[data-post-id]").getAttribute("data-post-id");
navigator.clipboard.writeText(postId).then(() => {
console.log('Post ID copied to clipboard:', postId);
});Drag the link below to your bookmarks bar, and click on it when you want to get a post ID from your blog:
Copy Ghost Post ID to Clipboard(Thanks to Chris Zarate’s for making the excellent bookmarklet encoder applet that I use every time I need to make a bookmarklet. It works great, and can even be saved and used offline.)