Skip to content

Commit 617f980

Browse files
committed
playground: update URL when clicking an example
1 parent ea9dceb commit 617f980

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

content/playground.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ Click an example to run it in the terminal:
104104
document.querySelectorAll('.playground-example').forEach(function(btn) {
105105
btn.addEventListener('click', function() {
106106
var cmd = btn.textContent;
107+
// Reflect the clicked example in the URL so it can be shared/bookmarked.
108+
var url = new URL(window.location.href);
109+
url.searchParams.set('cmd', cmd);
110+
history.replaceState(null, '', url);
107111
document.getElementById('wasm-playground').scrollIntoView({ behavior: 'smooth' });
108112
if (window.runInTerminal) {
109113
window.runInTerminal(cmd);

0 commit comments

Comments
 (0)