Fix page creation
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
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;
|
||||
@@ -5,7 +12,11 @@
|
||||
case 'E':
|
||||
e.preventDefault();
|
||||
window.location.href = window.location.pathname + '?edit';
|
||||
break;
|
||||
break;
|
||||
case 'N':
|
||||
e.preventDefault();
|
||||
newPage();
|
||||
break;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
<a class="btn-cancel" href="{{.PostURL}}">CANCEL</a>
|
||||
<button class="btn-save" type="submit" form="edit-form" data-action="save" data-key="S" title="Save (S)">SAVE</button>
|
||||
{{else if .CanEdit}}
|
||||
<a class="edit-btn" href="?edit" title="Edit (Alt+Shift+E)">EDIT</a>
|
||||
<button class="new-btn" onclick="newPage()" title="New page (N)">NEW</button>
|
||||
<a class="edit-btn" href="?edit" title="Edit page (E)">EDIT</a>
|
||||
{{end}}
|
||||
</header>
|
||||
<main>
|
||||
|
||||
@@ -102,6 +102,25 @@ header {
|
||||
color: #ffd54f;
|
||||
}
|
||||
|
||||
.new-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #ffb300;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.new-btn::before {
|
||||
content: "[";
|
||||
}
|
||||
.new-btn::after {
|
||||
content: "]";
|
||||
}
|
||||
.new-btn:hover {
|
||||
color: #ffd54f;
|
||||
}
|
||||
|
||||
/* === Main === */
|
||||
main {
|
||||
max-width: 860px;
|
||||
@@ -313,6 +332,7 @@ textarea:focus {
|
||||
color: #ffb300;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
text-shadow: inherit;
|
||||
padding: 0;
|
||||
}
|
||||
.btn-save::before {
|
||||
@@ -330,6 +350,7 @@ textarea:focus {
|
||||
border: none;
|
||||
color: #ffb300;
|
||||
font: inherit;
|
||||
text-shadow: inherit;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
text-decoration: none;
|
||||
|
||||
Reference in New Issue
Block a user