23 lines
648 B
JavaScript
23 lines
648 B
JavaScript
function newPage() {
|
|
const name = prompt('New page name:');
|
|
if (!name || !name.trim()) return;
|
|
const slug = name.trim().replace(/\s+/g, '-');
|
|
window.location.href = window.location.pathname + slug + '/?edit';
|
|
}
|
|
|
|
(function () {
|
|
document.addEventListener('keydown', function (e) {
|
|
if (!e.altKey || !e.shiftKey) return;
|
|
switch (e.key) {
|
|
case 'E':
|
|
e.preventDefault();
|
|
window.location.href = window.location.pathname + '?edit';
|
|
break;
|
|
case 'N':
|
|
e.preventDefault();
|
|
newPage();
|
|
break;
|
|
}
|
|
});
|
|
})();
|