From 9cbaecbb1e6d1025dc2be72b2bcbf020c5b8b1a1 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sun, 24 Dec 2017 12:05:54 -0500 Subject: [PATCH] Link the version text to the PR or changelog entry --- website/static/playground.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/website/static/playground.js b/website/static/playground.js index c47e3f094..60f5d8826 100644 --- a/website/static/playground.js +++ b/website/static/playground.js @@ -83,7 +83,25 @@ window.onload = function() { worker.onmessage = function(message) { if (prettierVersion === "?") { prettierVersion = message.data.version; - document.getElementById("version").textContent = prettierVersion; + + var link = document.createElement("a"); + var match = prettierVersion.match(/^pr-(\d+)$/); + if (match) { + link.href = "https://github.com/prettier/prettier/pull/" + match[1]; + link.textContent = "PR #" + match[1]; + } else { + if (prettierVersion.match(/\.0$/)) { + link.href = + "https://github.com/prettier/prettier/releases/tag/" + + prettierVersion; + } else { + link.href = + "https://github.com/j-f1/forked-prettier/blob/master/CHANGELOG.md#" + + prettierVersion; + } + link.textContent = "v" + prettierVersion; + } + document.getElementById("version").appendChild(link); } if (outputEditor && docEditor && astEditor) { outputEditor.setValue(message.data.formatted);