Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add text showing when a page was last updated #92

Merged
merged 1 commit into from
Nov 27, 2024
Merged
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
add last updated text
foodelevator committed Nov 25, 2024
commit 566755a6ee5510cc951d01038ca52d3fc022be1e
21 changes: 16 additions & 5 deletions src/components/Default/index.js
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ const RightSidebar = ({ sidebar, anchors }) => (
);

const taitanRenderer = (location, lang) =>
({ title, body, sidebar, nav, anchors, error }) => {
({ title, body, updated_at, sidebar, nav, anchors, error }) => {

// This useEffect solution is a workaround to prevent hydration errors when loading the Error page.
// useEffect does not run when doing serverside rendering, so this prevents the error page from
@@ -166,10 +166,21 @@ const taitanRenderer = (location, lang) =>

<div className="col-sm-8 col-md-9">
<div className="row">
<div
className="col-md-9"
dangerouslySetInnerHTML={{ __html: body }}
/>
<div className="col-md-9">
<div dangerouslySetInnerHTML={{ __html: body }} />
<Translate>
<Swedish>
<div className="align-right">
Senast uppdaterad {new Date(updated_at).toLocaleString("sv-SE", { year: "numeric", month: "long", day: "numeric" })}
</div>
</Swedish>
<English>
<div className="align-right">
Last updated {new Date(updated_at).toLocaleString("en-GB", { year: "numeric", month: "long", day: "numeric" })}
</div>
</English>
</Translate>
</div>
<RightSidebar sidebar={sidebar} anchors={anchors} />
</div>
</div>