Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions _components/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ export default function Feedback({ file }: { file: string | undefined }) {
return <></>;
} else {
const githubPath = "https://github.com/denoland/docs/edit/main" + file;

let modifiedDate = null;
try {
const dateString = new TextDecoder().decode(
(new Deno.Command("git", {
args: [
"log",
"-1",
"--pretty=%cI",
"./" + file,
],
})).outputSync().stdout,
);

modifiedDate = new Date(dateString);
} catch (e) {
console.log(e);
}

return (
<section
id="feedback-section"
Expand Down Expand Up @@ -138,6 +157,20 @@ export default function Feedback({ file }: { file: string | undefined }) {
</button>
</div>
</div>
{modifiedDate &&
(
<div class="mt-4">
This page was last modified on{" "}
<time datetime={modifiedDate.toString()}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<time datetime={modifiedDate.toString()}>
<time datetime={modifiedDate.toISOString()}>

The toString() method of Date instances returns a string representing this date interpreted in the local timezone.

toString() returns localized date; but <time> requires datetime in ISO8601 format.

{modifiedDate.toLocaleString("en", {
year: "numeric",
month: "short",
day: "numeric",
})}
</time>.
</div>
)}

<a
rel=""
class="mt-4 !underline underline-offset-2 text-xs block"
Expand Down