Skip to content

Commit

Permalink
Update next next-i18next, delete sass plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Santeri Rusila committed Oct 12, 2020
1 parent 30b3684 commit 749cc69
Show file tree
Hide file tree
Showing 8 changed files with 1,508 additions and 995 deletions.
18 changes: 10 additions & 8 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const withSass = require('@zeit/next-sass');
const { nextI18NextRewrites } = require('next-i18next/rewrites');

module.exports = withSass({
cssModules: true,
cssLoaderOptions: {
importLoaders: 1,
localIdentName: '[local]___[hash:base64:5]',
},
});
const localeSubpaths = {

This comment has been minimized.

Copy link
@jorilindell

jorilindell Oct 12, 2020

Contributor

We could define localeSubpaths only once. Now they are also defined at src/i18n.ts

fi: 'fi',
en: 'en',
sv: 'sv',
};

module.exports = {
rewrites: async () => nextI18NextRewrites(localeSubpaths),
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
"i18next-intervalplural-postprocessor": "^2.0.1",
"ics": "^2.22.1",
"jsdom": "^16.2.2",
"next": "9.4.4",
"next-i18next": "^4.4.2",
"next": "9.5.4",
"next-i18next": "^6.0.3",
"next-with-apollo": "^5.0.1",
"node-sass": "^4.14.1",
"query-string": "^6.13.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-i18next": "^11.5.0",
"react-i18next": "^11.7.3",
"react-redux": "^7.2.0",
"react-table": "^7.2.2",
"react-toastify": "^6.0.8",
Expand Down
5 changes: 4 additions & 1 deletion src/common/components/menuDropdown/MenuDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import useKeyboardNavigation from '../../../hooks/useDropdownKeyboardNavigation'
import { Language } from '../../../types';
import styles from './menuDropdown.module.scss';

const useIsomorphicLayoutEffect =
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;

This comment has been minimized.

Copy link
@jorilindell

jorilindell Oct 12, 2020

Contributor

Maybe isClient or similar helper function for window !== 'undefined'


export type MenuItem = {
icon?: React.ReactElement;
language?: Language;
Expand Down Expand Up @@ -170,7 +173,7 @@ const MenuDropdown: React.FC<MenuDropdownProps> = ({
}
};

React.useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
setupKeyboardNav();
document.addEventListener('click', onDocumentClick);
document.addEventListener('focusin', onDocumentFocusin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
--size-button-angle-icon: var(--spacing-layout-xs);

--spacing-button: var(--spacing-2-xs);
--spacing-menu-item: var(--spacing-s);
--spacing-menu-item: var(--spacing-xs);
}

.menuDropdown {
Expand Down
3 changes: 1 addition & 2 deletions src/domain/event/eventCard/EventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import styles from './eventCard.module.scss';
interface Props {
event: EventFieldsFragment;
link: string;
onClick?: (id: string) => void;
}

const EventCard: React.FC<Props> = ({ event, link, onClick }) => {
const EventCard: React.FC<Props> = ({ event, link }) => {
const { t } = useTranslation();
const locale = useLocale();

Expand Down
15 changes: 10 additions & 5 deletions src/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import path from 'path';

import intervalPlural from 'i18next-intervalplural-postprocessor';
import NextI18Next from 'next-i18next';

const localeSubpaths = {

This comment has been minimized.

Copy link
@jorilindell

jorilindell Oct 12, 2020

Contributor

Same constant was also defined at next.config.js

fi: 'fi',
en: 'en',
sv: 'sv',
};

const NextI18NextInstance = new NextI18Next({
defaultLanguage: 'fi',
ignoreRoutes: ['/healthz', '/readiness', '/_next', '/static', '/favicon.ico'],
localeSubpaths: {
en: 'en',
fi: 'fi',
sv: 'sv',
},
localeSubpaths,
otherLanguages: ['en', 'sv'],
localePath: path.resolve('./public/static/locales'),
});

NextI18NextInstance.i18n.use(intervalPlural);
Expand Down
7 changes: 0 additions & 7 deletions src/server.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import express from 'express';
import next from 'next';
import nextI18NextMiddleware from 'next-i18next/middleware';

import nextI18next from './i18n.ts';

const port = process.env.PORT || 3000;
const app = next({ dev: process.env.NODE_ENV !== 'production' });
Expand Down Expand Up @@ -31,10 +28,6 @@ const checkIsServerReady = (response) => {
await app.prepare();
const server = express();

await nextI18next.initPromise;

server.use(nextI18NextMiddleware(nextI18next));

server.get('/healthz', (req, res) => {
checkIsServerReady(res);
});
Expand Down

0 comments on commit 749cc69

Please sign in to comment.