diff --git a/src/pages/blog/[diary].astro b/src/pages/blog/[diary].astro
index bbd2c55..adff49f 100644
--- a/src/pages/blog/[diary].astro
+++ b/src/pages/blog/[diary].astro
@@ -46,5 +46,5 @@ if (diaryMain.data.repository) {
{ diaryPages.map((page) =>
{page.data.title}) }
-
+
\ No newline at end of file
diff --git a/src/pages/blog/[diary]/[entry].astro b/src/pages/blog/[diary]/[entry].astro
index efba7de..578c6eb 100644
--- a/src/pages/blog/[diary]/[entry].astro
+++ b/src/pages/blog/[diary]/[entry].astro
@@ -30,5 +30,5 @@ const { Content } = await entry.render();
-
+
diff --git a/src/pages/terminal.astro b/src/pages/terminal.astro
index 1571e24..82b3d3e 100644
--- a/src/pages/terminal.astro
+++ b/src/pages/terminal.astro
@@ -46,7 +46,20 @@ const wasmVersion = wasmData.version;
const screens = document.querySelectorAll("[data-terminal-screen]") as NodeListOf
;
const template = document.querySelector("[data-terminal-user-cmd]") as HTMLTemplateElement;
- screens.forEach((s) => s.addEventListener("click", () => inputs[0]?.focus()))
+ screens.forEach((s) => s.addEventListener("click", () => inputs[0]?.focus()));
+
+ screens.forEach((screen) => {
+ new MutationObserver((changes) => {
+ const totalNewHeight = changes.reduce((prev, change) => {
+ change.addedNodes.forEach(n => prev += (n as HTMLPreElement).clientHeight || 0);
+ return prev;
+ }, 0);
+
+ if (screen.scrollTop + screen.clientHeight >= screen.scrollHeight - totalNewHeight - 40) {
+ screen.scrollTo(0, screen.scrollHeight);
+ }
+ }).observe(screen, { childList: true, subtree: true });
+ });
const { default: init, Console } = await wasm;
@@ -69,9 +82,11 @@ const wasmVersion = wasmData.version;
inputLine.querySelector(".user-cmd")!.textContent = cmd;
inputLine.querySelector(".pwd")!.textContent = prevPwd;
outputs.forEach((output) => {
- output.prepend(inputLine);
+ output.append(inputLine);
});
+ input.value = "";
+
if (cmd) {
const resp = c.execute(cmd);
@@ -79,20 +94,15 @@ const wasmVersion = wasmData.version;
const outputLine = document.createElement("pre");
outputLine.textContent = resp
outputs.forEach((output) => {
- output.prepend(outputLine);
+ output.append(outputLine);
});
}
}
- input.value = "";
updatePwd();
}
});
});
-
- screens.forEach((screen) => {
- new MutationObserver(() => screen.scrollTo(0, screen.scrollHeight)).observe(screen, { childList: true, subtree: true });
- });
})()
@@ -127,7 +137,7 @@ const wasmVersion = wasmData.version;
[data-terminal-output] {
display: flex;
- flex-direction: column-reverse;
+ flex-direction: column;
}
}
@@ -164,6 +174,7 @@ const wasmVersion = wasmData.version;
appearance: none !important;
outline: none;
caret-shape: block;
+ color: #fff;
&::-moz-focus-outer, &::-moz-focus-inner, &:focus, &:focus *, &:-moz-focusring, &:-moz-focusring * {
border: none !important;