Skip to content

Commit

Permalink
Merge pull request #826 from fturmel/PR/stabilize-build-outputs
Browse files Browse the repository at this point in the history
Stabilize HTML build outputs
  • Loading branch information
shiffman committed Dec 16, 2022
2 parents f5c0b4b + 15267aa commit 8966474
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
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

0 comments on commit 8966474

Please sign in to comment.