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

Stabilize HTML build outputs #826

Merged
merged 2 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/components/ItemsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const ItemsPage = ({
selected={selectedLanguage}
onChange={setSelectedLanguage}
variant={variant}
instanceId="languages-filter"
/>

<Select
Expand All @@ -140,6 +141,7 @@ const ItemsPage = ({
selected={selectedTopic}
onChange={setSelectedTopic}
variant={variant}
instanceId="topics-filter"
/>
</div>

Expand Down
4 changes: 3 additions & 1 deletion src/components/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const Select = ({
onChange,
icon,
className,
variant
variant,
instanceId
}) => {
const opts = useMemo(() => options.map(toOption), [options]);
const handleOnChange = (o, action) => onChange(o ? o.value : o);
Expand All @@ -38,6 +39,7 @@ export const Select = ({
options={opts}
defaultValue={selected ? toOption(selected) : selected}
onChange={handleOnChange}
instanceId={instanceId}
/>

<div className={css.itemSpacer}></div>
Expand Down
19 changes: 15 additions & 4 deletions src/components/TopBar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { Link } from 'gatsby';

import Menu from './Menu';
Expand Down Expand Up @@ -39,7 +39,18 @@ const longDate = (date) => {
};

const TopBar = () => {
const today = new Date();
const [date, setDate] = useState({ long: '', short: '' });

useEffect(() => {
// Runs client-side only, the date should not be captured at build time during SSG

const today = new Date();
setDate({
long: longDate(today),
short: shortDate(today)
});
}, []);

return (
<div className={css.outer}>
<header className={css.root}>
Expand All @@ -50,8 +61,8 @@ const TopBar = () => {
</div>
<div className={css.clock}>🕛</div>
<div className={css.date}>
<span className={css.longDate}>{longDate(today)}</span>
<span className={css.shortDate}>{shortDate(today)}</span>
<span className={css.longDate}>{date.long}</span>
<span className={css.shortDate}>{date.short}</span>
</div>
<Menu />
</header>
Expand Down