From 383b22689629f96acbc71b309df547ff72a6695a Mon Sep 17 00:00:00 2001
From: Marco Biedermann <5244986+marcobiedermann@users.noreply.github.com.>
Date: Thu, 24 Oct 2024 11:22:25 +0200
Subject: [PATCH] refactor: Import/Exports
Refactor import and export statements
---
gatsby-browser.tsx | 4 +--
gatsby-ssr.tsx | 4 +--
src/components/Categories/Categories.tsx | 3 ++-
src/components/Layout/index.ts | 4 ---
src/components/index.ts | 26 +++++++++++++++++++
.../Default/Default.tsx} | 19 +++++---------
src/layouts/Default/index.ts | 4 +++
src/layouts/index.ts | 2 ++
src/pages/index.tsx | 4 +--
9 files changed, 45 insertions(+), 25 deletions(-)
delete mode 100644 src/components/Layout/index.ts
create mode 100644 src/components/index.ts
rename src/{components/Layout/Layout.tsx => layouts/Default/Default.tsx} (73%)
create mode 100644 src/layouts/Default/index.ts
create mode 100644 src/layouts/index.ts
diff --git a/gatsby-browser.tsx b/gatsby-browser.tsx
index e5c7cd3d..69e84fdf 100644
--- a/gatsby-browser.tsx
+++ b/gatsby-browser.tsx
@@ -3,11 +3,11 @@
import { WrapPageElementBrowserArgs } from 'gatsby';
import 'prismjs/themes/prism.css';
import React from 'react';
-import Layout from './src/components/Layout';
+import { Default } from './src/layouts';
import './src/styles/main.css';
function wrapPageElement({ element, props }: WrapPageElementBrowserArgs): JSX.Element {
- return {element};
+ return {element};
}
export { wrapPageElement };
diff --git a/gatsby-ssr.tsx b/gatsby-ssr.tsx
index eb66a44f..5bf03d42 100644
--- a/gatsby-ssr.tsx
+++ b/gatsby-ssr.tsx
@@ -2,10 +2,10 @@
import { WrapPageElementBrowserArgs } from 'gatsby';
import React from 'react';
-import Layout from './src/components/Layout';
+import { Default } from './src/layouts';
function wrapPageElement({ element, props }: WrapPageElementBrowserArgs): JSX.Element {
- return {element};
+ return {element};
}
export { wrapPageElement };
diff --git a/src/components/Categories/Categories.tsx b/src/components/Categories/Categories.tsx
index 4dbc74e9..6f41a24f 100644
--- a/src/components/Categories/Categories.tsx
+++ b/src/components/Categories/Categories.tsx
@@ -1,5 +1,6 @@
import React from 'react';
-import Category, { CategoryProps } from '../Category';
+import type { CategoryProps } from '../Category';
+import Category from '../Category';
import Section from '../Section';
interface CategoriesProps {
diff --git a/src/components/Layout/index.ts b/src/components/Layout/index.ts
deleted file mode 100644
index 6f0fb905..00000000
--- a/src/components/Layout/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import Layout from './Layout';
-
-export default Layout;
-export * from './Layout';
diff --git a/src/components/index.ts b/src/components/index.ts
new file mode 100644
index 00000000..a9d54678
--- /dev/null
+++ b/src/components/index.ts
@@ -0,0 +1,26 @@
+export * from './Aside';
+export { default as Aside } from './Aside';
+export * from './Categories';
+export { default as Categories } from './Categories';
+export * from './Column';
+export { default as Column } from './Column';
+export * from './Content';
+export { default as Content } from './Content';
+export * from './Footer';
+export { default as Footer } from './Footer';
+export * from './GitHub';
+export { default as GitHub } from './GitHub';
+export * from './Grid';
+export { default as Grid } from './Grid';
+export * from './Header';
+export { default as Header } from './Header';
+export * from './Main';
+export { default as Main } from './Main';
+export * from './Navigation';
+export { default as Navigation } from './Navigation';
+export * from './Row';
+export { default as Row } from './Row';
+export * from './Section';
+export { default as Section } from './Section';
+export * from './SEO';
+export { default as SEO } from './SEO';
diff --git a/src/components/Layout/Layout.tsx b/src/layouts/Default/Default.tsx
similarity index 73%
rename from src/components/Layout/Layout.tsx
rename to src/layouts/Default/Default.tsx
index 2cdd7bc7..74356f11 100644
--- a/src/components/Layout/Layout.tsx
+++ b/src/layouts/Default/Default.tsx
@@ -1,20 +1,13 @@
import { startCase } from 'lodash-es';
import React, { ReactNode } from 'react';
+import { Aside, Content, Footer, GitHub, Grid, Header, Main, Navigation } from '../../components';
import useIndexPage from '../../hooks';
-import Aside from '../Aside';
-import Content from '../Content';
-import Footer from '../Footer';
-import GitHub from '../GitHub';
-import Grid from '../Grid';
-import Header from '../Header';
-import Main from '../Main';
-import Navigation from '../Navigation';
-
-interface LayoutProps {
+
+interface DefaultProps {
children: ReactNode;
}
-function Layout(props: LayoutProps) {
+function Default(props: DefaultProps) {
const { children } = props;
const {
@@ -58,5 +51,5 @@ function Layout(props: LayoutProps) {
);
}
-export type { LayoutProps };
-export default Layout;
+export type { DefaultProps };
+export default Default;
diff --git a/src/layouts/Default/index.ts b/src/layouts/Default/index.ts
new file mode 100644
index 00000000..01af7105
--- /dev/null
+++ b/src/layouts/Default/index.ts
@@ -0,0 +1,4 @@
+import Default from './Default';
+
+export default Default;
+export * from './Default';
diff --git a/src/layouts/index.ts b/src/layouts/index.ts
new file mode 100644
index 00000000..54014d7d
--- /dev/null
+++ b/src/layouts/index.ts
@@ -0,0 +1,2 @@
+export * from './Default';
+export { default as Default } from './Default';
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index 601bce7b..6c878a3c 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -1,7 +1,5 @@
import React from 'react';
-import Categories from '../components/Categories';
-import Section from '../components/Section';
-import SEO from '../components/SEO';
+import { Categories, Section, SEO } from '../components';
import resources from '../constants/resources';
import tools from '../constants/tools';
import useIndexPage from '../hooks';