From 3a02c3910903e5d6f06c9fe097c3d08b5f083d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20=C5=A0korpil?= Date: Fri, 6 Jan 2023 23:06:03 +0100 Subject: [PATCH] Finished nextjs appdir adaptations --- Dockerfile | 13 +++---- application/src/app/feeds/head.tsx | 8 ++++ application/src/app/feeds/page.tsx | 2 +- application/src/app/head.tsx | 11 ++---- application/src/app/layout.tsx | 18 +++++++-- application/src/app/loading.tsx | 8 ++++ application/src/app/nodes/head.tsx | 8 ++++ application/src/app/nodes/page.tsx | 2 +- application/src/app/optout/head.tsx | 8 ++++ application/src/app/optout/page.tsx | 3 +- application/src/app/stats/head.tsx | 8 ++++ application/src/app/stats/page.tsx | 5 +-- application/src/components/Spinner.tsx | 6 +-- application/src/components/feed/FeedForm.tsx | 4 +- .../src/components/feed/FeedPlaceholder.tsx | 2 +- .../src/components/feed/FeedResults.tsx | 1 - .../src/components/feed/FeedSearch.tsx | 7 ++-- .../src/components/form/SubmitButton.tsx | 18 +++++++-- .../src/components/layout/ClientLayout.tsx | 27 ++----------- application/src/components/layout/Footer.tsx | 3 +- .../src/components/layout/HtmlHead.tsx | 20 ++++++++++ application/src/components/node/NodeForm.tsx | 4 +- .../src/components/node/NodePlaceholder.tsx | 39 +++++++++++-------- .../src/components/node/NodeSearch.tsx | 35 +++++++++++------ application/src/components/server/Layout.tsx | 8 +--- application/src/components/stats/Stats.tsx | 6 +-- .../src/components/stats/StatsPlaceholder.tsx | 7 +++- application/src/styles/global.scss | 4 +- 28 files changed, 177 insertions(+), 108 deletions(-) create mode 100644 application/src/app/feeds/head.tsx create mode 100644 application/src/app/loading.tsx create mode 100644 application/src/app/nodes/head.tsx create mode 100644 application/src/app/optout/head.tsx create mode 100644 application/src/app/stats/head.tsx create mode 100644 application/src/components/layout/HtmlHead.tsx diff --git a/Dockerfile b/Dockerfile index 7d07ff4..e0d98a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ FROM node:18-bullseye AS prebuild + FROM prebuild AS build WORKDIR /srv COPY application/package*.json ./ +COPY application/yarn.lock ./ RUN yarn install COPY application/. . -RUN chmod -R uog+r . RUN yarn build FROM build as dev @@ -12,13 +13,9 @@ CMD yarn dev FROM prebuild AS prod RUN groupadd -g 1001 nodejs -RUN useradd -u 1001 -g 1001 nextjs +RUN useradd -m -u 1001 -g 1001 nextjs USER nextjs EXPOSE 3000 WORKDIR /srv -COPY --from=build /srv/node_modules ./node_modules -COPY --from=build /srv/package*.json ./ -COPY --from=build /srv/next.config.js ./ -COPY --from=build --chown=nextjs:nodejs /srv/src/.next ./src/.next -COPY --from=build /srv/src/public ./src/public -CMD yarn start +COPY --from=build --chown=nextjs:nodejs /srv/. ./ +CMD yarn build && yarn start diff --git a/application/src/app/feeds/head.tsx b/application/src/app/feeds/head.tsx new file mode 100644 index 0000000..1884fe4 --- /dev/null +++ b/application/src/app/feeds/head.tsx @@ -0,0 +1,8 @@ +import React, { ReactElement } from 'react' +import HtmlHead from '../../components/layout/HtmlHead' + +export default function Head (): ReactElement { + return <> + + +} diff --git a/application/src/app/feeds/page.tsx b/application/src/app/feeds/page.tsx index b0c12bc..cc2d82a 100644 --- a/application/src/app/feeds/page.tsx +++ b/application/src/app/feeds/page.tsx @@ -6,7 +6,7 @@ import createConfig from '../../config/createConfig' export default async function Page (): Promise { const clientConfig = createConfig().get('client') return ( - + ) diff --git a/application/src/app/head.tsx b/application/src/app/head.tsx index db9659e..dcda320 100644 --- a/application/src/app/head.tsx +++ b/application/src/app/head.tsx @@ -1,11 +1,6 @@ -import { ReactElement } from 'react' +import React, { ReactElement } from 'react' +import HtmlHead from '../components/layout/HtmlHead' export default function Head (): ReactElement { - return ( - <> - - - - - ) + return } diff --git a/application/src/app/layout.tsx b/application/src/app/layout.tsx index e33333e..a8ff970 100644 --- a/application/src/app/layout.tsx +++ b/application/src/app/layout.tsx @@ -1,4 +1,7 @@ import React, { ReactElement } from 'react' +import Footer from '../components/layout/Footer' +import NavBar from '../components/layout/NavBar' +import '../styles/global.scss' export default function RootLayout ({ children @@ -6,9 +9,16 @@ export default function RootLayout ({ children: React.ReactNode }): ReactElement { return ( - - - {children} - + + +
+ +
+ {children} +
+
+
+ + ) } diff --git a/application/src/app/loading.tsx b/application/src/app/loading.tsx new file mode 100644 index 0000000..42602cd --- /dev/null +++ b/application/src/app/loading.tsx @@ -0,0 +1,8 @@ +import React, { ReactElement } from 'react' + +export default function Loading (): ReactElement { + console.log('Loading') + return
+

+
+} diff --git a/application/src/app/nodes/head.tsx b/application/src/app/nodes/head.tsx new file mode 100644 index 0000000..65050c0 --- /dev/null +++ b/application/src/app/nodes/head.tsx @@ -0,0 +1,8 @@ +import React, { ReactElement } from 'react' +import HtmlHead from '../../components/layout/HtmlHead' + +export default function Head (): ReactElement { + return <> + + +} diff --git a/application/src/app/nodes/page.tsx b/application/src/app/nodes/page.tsx index 6d3002d..7b84166 100644 --- a/application/src/app/nodes/page.tsx +++ b/application/src/app/nodes/page.tsx @@ -6,7 +6,7 @@ import createConfig from '../../config/createConfig' export default async function Page (): Promise { const clientConfig = createConfig().get('client') return ( - + ) diff --git a/application/src/app/optout/head.tsx b/application/src/app/optout/head.tsx new file mode 100644 index 0000000..a806a59 --- /dev/null +++ b/application/src/app/optout/head.tsx @@ -0,0 +1,8 @@ +import React, { ReactElement } from 'react' +import HtmlHead from '../../components/layout/HtmlHead' + +export default function Head (): ReactElement { + return <> + + +} diff --git a/application/src/app/optout/page.tsx b/application/src/app/optout/page.tsx index 39fa63a..c2d4565 100644 --- a/application/src/app/optout/page.tsx +++ b/application/src/app/optout/page.tsx @@ -1,6 +1,5 @@ import React, { ReactElement } from 'react' import Accordion from '../../components/accordion/Accordion' -import AccordionItem from '../../components/accordion/AccordionItem' import MastodonNoindexOptout from '../../components/optout/MastodonNoindexOptout' import MastodonSuggestingOptout from '../../components/optout/MastodonSuggestingOptout' import RobotsTxtOptout from '../../components/optout/RobotsTxtOptout' @@ -11,7 +10,7 @@ import createConfig from '../../config/createConfig' export default async function Page (): Promise { const clientConfig = createConfig().get('client') return ( - +

You don't want to be listed here? There are several ways to opt-out from our index:

diff --git a/application/src/app/stats/head.tsx b/application/src/app/stats/head.tsx new file mode 100644 index 0000000..7a48a5d --- /dev/null +++ b/application/src/app/stats/head.tsx @@ -0,0 +1,8 @@ +import React, { ReactElement } from 'react' +import HtmlHead from '../../components/layout/HtmlHead' + +export default function Head (): ReactElement { + return <> + + +} diff --git a/application/src/app/stats/page.tsx b/application/src/app/stats/page.tsx index 11de63d..544683f 100644 --- a/application/src/app/stats/page.tsx +++ b/application/src/app/stats/page.tsx @@ -1,13 +1,12 @@ import React, { ReactElement } from 'react' -import NodeSearch from '../../components/node/NodeSearch' import Layout from '../../components/server/Layout' -import Stats from "../../components/stats/Stats"; +import Stats from '../../components/stats/Stats' import createConfig from '../../config/createConfig' export default async function Page (): Promise { const clientConfig = createConfig().get('client') return ( - + ) diff --git a/application/src/components/Spinner.tsx b/application/src/components/Spinner.tsx index 44a295f..2e34d69 100644 --- a/application/src/components/Spinner.tsx +++ b/application/src/components/Spinner.tsx @@ -1,11 +1,9 @@ -import React from 'react' +import React, { ReactElement } from 'react' -const Spinner: React.FC = () => { +export default function Spinner (): ReactElement { return (
Loading...
) } - -export default Spinner diff --git a/application/src/components/feed/FeedForm.tsx b/application/src/components/feed/FeedForm.tsx index 064ddea..ca9439c 100644 --- a/application/src/components/feed/FeedForm.tsx +++ b/application/src/components/feed/FeedForm.tsx @@ -6,10 +6,11 @@ import SearchInput from '../form/SearchInput' import SubmitButton from '../form/SubmitButton' export default function FeedForm ( - { onSubmit, onQueryChange, query }: { + { onSubmit, onQueryChange, query, loading }: { onSubmit: () => void onQueryChange: (query: FeedQueryInput) => void query: FeedQueryInput + loading?: boolean } ): ReactElement { const handleQueryChange = (event): void => { @@ -41,6 +42,7 @@ export default function FeedForm ( diff --git a/application/src/components/feed/FeedPlaceholder.tsx b/application/src/components/feed/FeedPlaceholder.tsx index 629e80c..f38b777 100644 --- a/application/src/components/feed/FeedPlaceholder.tsx +++ b/application/src/components/feed/FeedPlaceholder.tsx @@ -7,7 +7,7 @@ import Badge from './badges/Badge' export default function FeedPlaceholder (): ReactElement { const greyDotBlob = 'data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==' return ( -