20200513-14 Julie Kwok
see demo here
Page behaviour
- Default language is FR. On top right, there are 2 btns for the other 2 available languages. Hover shows indication, click changes site language.
- Last used language is saved for next visit.
- All languages share a common url on the same page
- Click on navbar links to see 3 main pages
- Click on link of
works
page for separated cases
Other disclosures
- all pages except for home is render with exactly the same component.
- Can handle cases where translation doesn't fil the original in terms of number of sections or paragraphs. But CSS is always the same: a
h3
and ap
- To add translations, pages and case, only need to 1) add jsons in
Translations
, add language flag inimages
, add language inindex.jsx
, add corresponding items inConstants
. Everthing else is done by iteration. - It is SLOW on localhost (I imagine given all the iterations) but now.sh seems to be OK
- the
.env
is not ignored because, really, there is nothing sensitive
Discoveries
-
Chinese quotes don't need to be escaped in json, but numbers do have to be quoted.
-
Closing a tab or a page won't trigger
unmount
hook. Things are interrupted so no way of doing anything. To save the "last" language preference, I actually had to save it every time it changes. -
So...if there is no
exact
inRoute
of/
, you might have the content of/
before the content of any page. Exact means exact: the path will be "root + what you write", elimination any possible existing url params. -
Oh my god why are there footers in the world ?
- it seems that a negative margin-bottom and a hight keeps them where they belong
position:absolute;
pluswidth:100%;
will go all along to the right extreme ignoring whatever margin and padding on the right you might have
-
If there are things I only do in useEffect, I shall avoid defining it outside of the effect, so that not to trigger warning.
-
Seems that
/
path doesn't get to use dynamic routing coz slug isundefined
. It is possible to add optional slugs (after something that is sure to exist but before nothing else) by adding:optionalSlug?
-
There is a guide to deploy on
now.sh
here, just that the npm package and the command are now "vercel" instead of "now" -
To have a docile footer that always sticks to the bottom, see (here)[https://matthewjamestaylor.com/bottom-footer] (I kinda feel that the essential is not using
<footer>
but<div id="footer"/>
)
Difficulties
- Didn't manage the url separation for languages.
- quite easy to have a separated Url that updates but page wouldn't fill
- language changes, URL stays the same
- did try out dynamic routing and language basename for every page. Now when I change the lang with a btn, URL is still the same. If I change manually the url and even refresh, the content doesn't change
react-router-dom
has auseHistory
option. But it does not give access to the lang basename.- .........
- hmmm at this time, type
/whatever/a-valid-case-study
will lead you to the case page...
Bug report