From ae5e37c002793446d41d536820128a0d08b81854 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 6 Mar 2022 01:21:43 +0100 Subject: [PATCH 01/19] Create node.js.yml --- .github/workflows/node.js.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..57e68ee --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,30 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present -- 2.40.1 From e4def9268a8be59cbc497a395066927b61bf1269 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 6 Mar 2022 01:37:16 +0100 Subject: [PATCH 02/19] Update node.js.yml --- .github/workflows/node.js.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 57e68ee..40abb72 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x, 16.x] + node-version: [16.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -26,5 +26,11 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' + env: + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} + NEXT_PUBLIC_URL_CMS: ${{ secrets.NEXT_PUBLIC_URL_CMS }} + NEXT_PUBLIC_URL_IMG: ${{ secrets.NEXT_PUBLIC_URL_IMG }} + NEXT_PUBLIC_URL_SELF: ${{ secrets.NEXT_PUBLIC_URL_SELF }} + URL_GRAPHQL: ${{ secrets.URL_GRAPHQL }} - run: npm ci - run: npm run build --if-present -- 2.40.1 From d502655dff2d1af0cee95c33d722df20b8ee24ae Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 6 Mar 2022 02:01:49 +0100 Subject: [PATCH 03/19] Update node.js.yml --- .github/workflows/node.js.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 40abb72..4260864 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,11 +26,19 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' + - name: Create .env.local file env: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} NEXT_PUBLIC_URL_CMS: ${{ secrets.NEXT_PUBLIC_URL_CMS }} NEXT_PUBLIC_URL_IMG: ${{ secrets.NEXT_PUBLIC_URL_IMG }} NEXT_PUBLIC_URL_SELF: ${{ secrets.NEXT_PUBLIC_URL_SELF }} URL_GRAPHQL: ${{ secrets.URL_GRAPHQL }} + run: | + touch .env.local + echo ACCESS_TOKEN=${{ secrets.ACCESS_TOKEN }} >> .env.local + echo NEXT_PUBLIC_URL_CMS=${{ secrets.NEXT_PUBLIC_URL_CMS }} >> .env.local + echo NEXT_PUBLIC_URL_IMG=${{ secrets.NEXT_PUBLIC_URL_IMG }} >> .env.local + echo NEXT_PUBLIC_URL_SELF=${{ secrets.NEXT_PUBLIC_URL_SELF }} >> .env.local + echo URL_GRAPHQL=${{ secrets.URL_GRAPHQL }} >> .env.local - run: npm ci - run: npm run build --if-present -- 2.40.1 From 29faaf8051581b165dd1c85ef20f5dbd031d7cf8 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 6 Mar 2022 02:04:36 +0100 Subject: [PATCH 04/19] Update node.js.yml --- .github/workflows/node.js.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 4260864..cfe1ff6 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -40,5 +40,6 @@ jobs: echo NEXT_PUBLIC_URL_IMG=${{ secrets.NEXT_PUBLIC_URL_IMG }} >> .env.local echo NEXT_PUBLIC_URL_SELF=${{ secrets.NEXT_PUBLIC_URL_SELF }} >> .env.local echo URL_GRAPHQL=${{ secrets.URL_GRAPHQL }} >> .env.local + cat .env.local - run: npm ci - run: npm run build --if-present -- 2.40.1 From 9ecabfc2f3c93dfbf72e797bb46c04e687d4d6fe Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 6 Mar 2022 02:08:16 +0100 Subject: [PATCH 05/19] Update node.js.yml --- .github/workflows/node.js.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index cfe1ff6..2e4dbe1 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,20 +26,11 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' - - name: Create .env.local file + - run: npm ci + - run: npm run build --if-present env: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} NEXT_PUBLIC_URL_CMS: ${{ secrets.NEXT_PUBLIC_URL_CMS }} NEXT_PUBLIC_URL_IMG: ${{ secrets.NEXT_PUBLIC_URL_IMG }} NEXT_PUBLIC_URL_SELF: ${{ secrets.NEXT_PUBLIC_URL_SELF }} URL_GRAPHQL: ${{ secrets.URL_GRAPHQL }} - run: | - touch .env.local - echo ACCESS_TOKEN=${{ secrets.ACCESS_TOKEN }} >> .env.local - echo NEXT_PUBLIC_URL_CMS=${{ secrets.NEXT_PUBLIC_URL_CMS }} >> .env.local - echo NEXT_PUBLIC_URL_IMG=${{ secrets.NEXT_PUBLIC_URL_IMG }} >> .env.local - echo NEXT_PUBLIC_URL_SELF=${{ secrets.NEXT_PUBLIC_URL_SELF }} >> .env.local - echo URL_GRAPHQL=${{ secrets.URL_GRAPHQL }} >> .env.local - cat .env.local - - run: npm ci - - run: npm run build --if-present -- 2.40.1 From b95278ddbee48197fabf5fde0c85a584b1310646 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 6 Mar 2022 02:23:52 +0100 Subject: [PATCH 06/19] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6b245ca..c3bec14 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Accords-library.com +[![Node.js CI](https://github.com/Accords-Library/accords-library.com/actions/workflows/node.js.yml/badge.svg?branch=main)](https://github.com/Accords-Library/accords-library.com/actions/workflows/node.js.yml) + ## Technologies #### [Back](https://github.com/Accords-Library/strapi.accords-library.com) -- 2.40.1 From 46dab30ebede78bb105a0506d57202a5cf53d8bd Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 6 Mar 2022 04:49:51 +0100 Subject: [PATCH 07/19] Update node.js.yml --- .github/workflows/node.js.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 2e4dbe1..a7f6d4e 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -4,8 +4,8 @@ name: Node.js CI on: - push: - branches: [ main ] +# push: +# branches: [ main ] pull_request: branches: [ main ] -- 2.40.1 From aba8d373d56c514804d709e6e4fccd5761f94abd Mon Sep 17 00:00:00 2001 From: DrMint Date: Fri, 11 Mar 2022 01:08:33 +0100 Subject: [PATCH 08/19] Update node.js.yml --- .github/workflows/node.js.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index a7f6d4e..a5242e0 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -27,6 +27,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm ci + - run: npm run lint - run: npm run build --if-present env: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} -- 2.40.1 From f2d99f5dcd135401f2da64159959e9b748531e21 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 13 Mar 2022 16:26:21 +0100 Subject: [PATCH 09/19] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2d8f00e..ab29d20 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Accords-library.com [![Node.js CI](https://github.com/Accords-Library/accords-library.com/actions/workflows/node.js.yml/badge.svg?branch=main)](https://github.com/Accords-Library/accords-library.com/actions/workflows/node.js.yml) +[![GitHub](https://img.shields.io/github/license/Accords-Library/accords-library.com?style=flat-square)](https://github.com/Accords-Library/accords-library.com/blob/main/LICENSE) +![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/Accords-Library/accords-library.com?style=flat-square) ## Technologies -- 2.40.1 From 76a44457e48e98e620becd2155682b6d0a112faa Mon Sep 17 00:00:00 2001 From: DrMint Date: Sat, 19 Mar 2022 17:31:36 +0100 Subject: [PATCH 10/19] Added more pages in about us --- src/pages/about-us/accords-handbook.tsx | 87 +++++++++++++++++++ src/pages/about-us/index.tsx | 8 +- .../{site-information.tsx => legality.tsx} | 31 ++++++- src/pages/about-us/sharing-policy.tsx | 85 ++++++++++++++++++ 4 files changed, 204 insertions(+), 7 deletions(-) create mode 100644 src/pages/about-us/accords-handbook.tsx rename src/pages/about-us/{site-information.tsx => legality.tsx} (63%) create mode 100644 src/pages/about-us/sharing-policy.tsx diff --git a/src/pages/about-us/accords-handbook.tsx b/src/pages/about-us/accords-handbook.tsx new file mode 100644 index 0000000..43946a9 --- /dev/null +++ b/src/pages/about-us/accords-handbook.tsx @@ -0,0 +1,87 @@ +import AppLayout from "components/AppLayout"; +import Markdawn from "components/Markdown/Markdawn"; +import TOC from "components/Markdown/TOC"; +import ReturnButton, { + ReturnButtonType, +} from "components/PanelComponents/ReturnButton"; +import ContentPanel from "components/Panels/ContentPanel"; +import SubPanel from "components/Panels/SubPanel"; +import { getPost } from "graphql/operations"; +import { GetPostQuery } from "graphql/operations-types"; +import { GetStaticProps } from "next"; +import { useRouter } from "next/router"; +import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; +import { prettySlug } from "queries/helpers"; + +interface AccordsHandbookProps extends AppStaticProps { + post: GetPostQuery["posts"]["data"][number]["attributes"]; +} + +export default function AccordsHandbook( + props: AccordsHandbookProps +): JSX.Element { + const { langui, post } = props; + const router = useRouter(); + + const subPanel = ( + + + {post.translations.length > 0 && post.translations[0].body && ( + + )} + + ); + + const contentPanel = ( + + + {post.translations.length > 0 && ( + + )} + + ); + + return ( + 0 + ? post.translations[0].title + : prettySlug(post.slug) + } + subPanel={subPanel} + contentPanel={contentPanel} + {...props} + /> + ); +} + +export const getStaticProps: GetStaticProps = async (context) => { + const props: AccordsHandbookProps = { + ...(await getAppStaticProps(context)), + post: ( + await getPost({ + slug: "accords-handbook", + language_code: context.locale || "en", + }) + ).posts.data[0].attributes, + }; + return { + props: props, + }; +}; diff --git a/src/pages/about-us/index.tsx b/src/pages/about-us/index.tsx index 32fdb35..5b0af29 100644 --- a/src/pages/about-us/index.tsx +++ b/src/pages/about-us/index.tsx @@ -16,13 +16,13 @@ export default function AboutUs(props: AboutUsProps): JSX.Element { title={langui.about_us} description={langui.about_us_description} /> - + - + diff --git a/src/pages/about-us/site-information.tsx b/src/pages/about-us/legality.tsx similarity index 63% rename from src/pages/about-us/site-information.tsx rename to src/pages/about-us/legality.tsx index 8ff04c8..d773386 100644 --- a/src/pages/about-us/site-information.tsx +++ b/src/pages/about-us/legality.tsx @@ -1,12 +1,15 @@ import AppLayout from "components/AppLayout"; import Markdawn from "components/Markdown/Markdawn"; +import TOC from "components/Markdown/TOC"; import ReturnButton, { ReturnButtonType, } from "components/PanelComponents/ReturnButton"; import ContentPanel from "components/Panels/ContentPanel"; +import SubPanel from "components/Panels/SubPanel"; import { getPost } from "graphql/operations"; import { GetPostQuery } from "graphql/operations-types"; import { GetStaticProps } from "next"; +import { useRouter } from "next/router"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; import { prettySlug } from "queries/helpers"; @@ -16,17 +19,38 @@ interface SiteInfoProps extends AppStaticProps { export default function SiteInformation(props: SiteInfoProps): JSX.Element { const { langui, post } = props; + const router = useRouter(); + + const subPanel = ( + + + {post.translations.length > 0 && post.translations[0].body && ( + + )} + + ); + const contentPanel = ( {post.translations.length > 0 && ( - + )} ); @@ -38,6 +62,7 @@ export default function SiteInformation(props: SiteInfoProps): JSX.Element { ? post.translations[0].title : prettySlug(post.slug) } + subPanel={subPanel} contentPanel={contentPanel} {...props} /> @@ -49,7 +74,7 @@ export const getStaticProps: GetStaticProps = async (context) => { ...(await getAppStaticProps(context)), post: ( await getPost({ - slug: "site-information", + slug: "legality", language_code: context.locale || "en", }) ).posts.data[0].attributes, diff --git a/src/pages/about-us/sharing-policy.tsx b/src/pages/about-us/sharing-policy.tsx new file mode 100644 index 0000000..aea24e4 --- /dev/null +++ b/src/pages/about-us/sharing-policy.tsx @@ -0,0 +1,85 @@ +import AppLayout from "components/AppLayout"; +import Markdawn from "components/Markdown/Markdawn"; +import TOC from "components/Markdown/TOC"; +import ReturnButton, { + ReturnButtonType, +} from "components/PanelComponents/ReturnButton"; +import ContentPanel from "components/Panels/ContentPanel"; +import SubPanel from "components/Panels/SubPanel"; +import { getPost } from "graphql/operations"; +import { GetPostQuery } from "graphql/operations-types"; +import { GetStaticProps } from "next"; +import { useRouter } from "next/router"; +import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; +import { prettySlug } from "queries/helpers"; + +interface SharingPolicyProps extends AppStaticProps { + post: GetPostQuery["posts"]["data"][number]["attributes"]; +} + +export default function SharingPolicy(props: SharingPolicyProps): JSX.Element { + const { langui, post } = props; + const router = useRouter(); + + const subPanel = ( + + + {post.translations.length > 0 && post.translations[0].body && ( + + )} + + ); + + const contentPanel = ( + + + {post.translations.length > 0 && ( + + )} + + ); + + return ( + 0 + ? post.translations[0].title + : prettySlug(post.slug) + } + subPanel={subPanel} + contentPanel={contentPanel} + {...props} + /> + ); +} + +export const getStaticProps: GetStaticProps = async (context) => { + const props: SharingPolicyProps = { + ...(await getAppStaticProps(context)), + post: ( + await getPost({ + slug: "sharing-policy", + language_code: context.locale || "en", + }) + ).posts.data[0].attributes, + }; + return { + props: props, + }; +}; -- 2.40.1 From c48ff5249b6db4b80dd8b737c688ecd224866e7a Mon Sep 17 00:00:00 2001 From: DrMint Date: Sat, 19 Mar 2022 17:32:23 +0100 Subject: [PATCH 11/19] Reintroduced the wiki pages --- src/components/Panels/MainPanel.tsx | 5 ++--- src/pages/wiki/chronology.tsx | 20 ++++++++++++++++++++ src/pages/wiki/index.tsx | 3 +++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/components/Panels/MainPanel.tsx b/src/components/Panels/MainPanel.tsx index a705e48..3275f19 100644 --- a/src/components/Panels/MainPanel.tsx +++ b/src/components/Panels/MainPanel.tsx @@ -155,18 +155,17 @@ export default function MainPanel(props: MainPanelProps): JSX.Element { onClick={() => appLayout.setMainPanelOpen(false)} /> - {/* - appLayout.setMainPanelOpen(false)} /> + {/* + + + {chronologyEras.map((era) => ( + + + {chronologyItemYearGroups.map((era, eraIndex) => ( <> + ); -- 2.40.1 From de6b0fe017677d9fc21b08def6e3324c5b20ba7e Mon Sep 17 00:00:00 2001 From: DrMint Date: Sat, 19 Mar 2022 17:35:17 +0100 Subject: [PATCH 12/19] Improved markdawn by adding more functionalities --- src/components/Markdown/Markdawn.tsx | 107 ++++++++++++++++++--------- src/components/Markdown/TOC.tsx | 2 +- src/pages/_app.tsx | 2 + src/pages/contents/[slug]/read.tsx | 2 +- src/pages/editor.tsx | 4 +- src/pages/index.tsx | 5 +- src/pages/news/[slug].tsx | 2 +- src/queries/helpers.ts | 5 +- src/tailwind.css | 14 +++- 9 files changed, 100 insertions(+), 43 deletions(-) diff --git a/src/components/Markdown/Markdawn.tsx b/src/components/Markdown/Markdawn.tsx index 4cb08c1..83f743b 100644 --- a/src/components/Markdown/Markdawn.tsx +++ b/src/components/Markdown/Markdawn.tsx @@ -5,18 +5,22 @@ import LightBox from "components/LightBox"; import ToolTip from "components/ToolTip"; import { useAppLayout } from "contexts/AppLayoutContext"; import Markdown from "markdown-to-jsx"; +import { NextRouter } from "next/router"; import { slugify } from "queries/helpers"; import React, { useState } from "react"; -type ScenBreakProps = { +type MarkdawnProps = { className?: string; text: string; + router: NextRouter; }; -export default function Markdawn(props: ScenBreakProps): JSX.Element { +export default function Markdawn(props: MarkdawnProps): JSX.Element { const appLayout = useAppLayout(); const text = preprocessMarkDawn(props.text); + const { router } = props; + const [lightboxOpen, setLightboxOpen] = useState(false); const [lightboxImages, setLightboxImages] = useState([""]); const [lightboxIndex, setLightboxIndex] = useState(0); @@ -43,12 +47,10 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { children: React.ReactNode; }) => { return ( -
-

- {props.children} -

+

+ {props.children} -

+ ); }, }, @@ -59,12 +61,10 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { children: React.ReactNode; }) => { return ( -
-

- {props.children} -

+

+ {props.children} -

+ ); }, }, @@ -75,12 +75,10 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { children: React.ReactNode; }) => { return ( -
-

- {props.children} -

+

+ {props.children} -

+ ); }, }, @@ -91,12 +89,10 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { children: React.ReactNode; }) => { return ( -
-

- {props.children} -

+

+ {props.children} -

+ ); }, }, @@ -107,12 +103,10 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { children: React.ReactNode; }) => { return ( -
-
- {props.children} -
+
+ {props.children} -
+ ); }, }, @@ -123,12 +117,10 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { children: React.ReactNode; }) => { return ( -
-
- {props.children} -
+
+ {props.children} -
+ ); }, }, @@ -151,6 +143,28 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { ); }, }, + IntraLink: { + component: (props: { + children: React.ReactNode; + target?: string; + page?: string; + }) => { + const slug = props.target + ? slugify(props.target) + : slugify(props.children?.toString()); + return ( + + router.replace( + `${props.page ? props.page : ""}#${slug}` + ) + } + > + {props.children} + + ); + }, + }, player: { component: () => { return ( @@ -219,6 +233,25 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { ); }, }, + blockquote: { + component: (props: { + children: React.ReactNode; + cite?: string; + }) => { + return ( +
+ {props.cite ? ( + <> + “{props.children}” + — {props.cite} + + ) : ( + props.children + )} +
+ ); + }, + }, img: { component: (props: { alt: string; @@ -230,7 +263,7 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { }) => { return (
{ setLightboxOpen(true); setLightboxImages([ @@ -280,8 +313,12 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { function HeaderToolTip(props: { id: string }) { return ( - - + + { diff --git a/src/components/Markdown/TOC.tsx b/src/components/Markdown/TOC.tsx index 8e50a0e..aed7dfb 100644 --- a/src/components/Markdown/TOC.tsx +++ b/src/components/Markdown/TOC.tsx @@ -49,7 +49,7 @@ function TOCLevel(props: TOCLevelProps): JSX.Element { > {`${parentNumbering}${ childIndex + 1 - }.`} + }.`}{" "} router.replace(`#${child.slug}`)}> {{child.title}} diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index b073451..1f34c1a 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,8 +1,10 @@ import type { AppProps } from "next/app"; import "tailwind.css"; import "@fontsource/zen-maru-gothic/500.css"; +import "@fontsource/zen-maru-gothic/900.css"; import "@fontsource/vollkorn/700.css"; import "@fontsource/opendyslexic/400.css"; +import "@fontsource/opendyslexic/700.css"; import "@fontsource/material-icons"; import { AppContextProvider } from "contexts/AppLayoutContext"; diff --git a/src/pages/contents/[slug]/read.tsx b/src/pages/contents/[slug]/read.tsx index c770ebf..25573b2 100644 --- a/src/pages/contents/[slug]/read.tsx +++ b/src/pages/contents/[slug]/read.tsx @@ -187,7 +187,7 @@ export default function ContentRead(props: ContentReadProps): JSX.Element { {content.text_set.length > 0 && content.text_set[0].text && ( - + )}
diff --git a/src/pages/editor.tsx b/src/pages/editor.tsx index 825ed90..b770c0e 100644 --- a/src/pages/editor.tsx +++ b/src/pages/editor.tsx @@ -7,11 +7,13 @@ import { useCallback, useState } from "react"; import Markdawn from "components/Markdown/Markdawn"; import Script from "next/script"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; +import { useRouter } from "next/router"; interface EditorProps extends AppStaticProps {} export default function Editor(props: EditorProps): JSX.Element { const { langui } = props; + const router = useRouter(); const handleInput = useCallback((e) => { setMarkdown(e.target.value); @@ -76,7 +78,7 @@ export default function Editor(props: EditorProps): JSX.Element {

Preview

- +
diff --git a/src/pages/index.tsx b/src/pages/index.tsx index d65e0d6..0e002ab 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -4,6 +4,7 @@ import ContentPanel from "components/Panels/ContentPanel"; import { getPost } from "graphql/operations"; import { GetPostQuery } from "graphql/operations-types"; import { GetStaticProps } from "next"; +import { useRouter } from "next/router"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; import { prettySlug } from "queries/helpers"; @@ -13,6 +14,8 @@ interface HomeProps extends AppStaticProps { export default function Home(props: HomeProps): JSX.Element { const { post } = props; + const router = useRouter(); + const contentPanel = (
@@ -23,7 +26,7 @@ export default function Home(props: HomeProps): JSX.Element {
{post.translations.length > 0 && ( - + )}
); diff --git a/src/pages/news/[slug].tsx b/src/pages/news/[slug].tsx index 3a7334a..3ee7b54 100644 --- a/src/pages/news/[slug].tsx +++ b/src/pages/news/[slug].tsx @@ -108,7 +108,7 @@ export default function LibrarySlug(props: PostProps): JSX.Element { {post.translations.length > 0 && post.translations[0].body && ( - + )} ); diff --git a/src/queries/helpers.ts b/src/queries/helpers.ts index 9e7200c..7393aa1 100644 --- a/src/queries/helpers.ts +++ b/src/queries/helpers.ts @@ -274,8 +274,9 @@ export function getStatusDescription( } } -export function slugify(str: string): string { - return str +export function slugify(string: string | undefined): string { + if (!string) return ""; + return string .replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g, "a") .replace(/[çÇ]/g, "c") .replace(/[ðÐ]/g, "d") diff --git a/src/tailwind.css b/src/tailwind.css index 14a9584..80f03cd 100644 --- a/src/tailwind.css +++ b/src/tailwind.css @@ -54,7 +54,7 @@ .formatted h4, .formatted h5, .formatted h6 { - @apply text-center; + @apply text-center flex gap-3 justify-center; } .formatted h1 { @@ -94,6 +94,10 @@ @apply my-2 text-justify; } + .formatted strong { + @apply font-black; + } + .formatted footer { @apply border-t-[3px] border-dotted pt-6; } @@ -122,6 +126,14 @@ @apply list-decimal pl-4; } + .formatted blockquote { + @apply border-2 border-mid rounded-lg p-5 text-center my-8; + } + + .formatted blockquote cite { + @apply text-dark block; + } + /* INPUT */ input { -- 2.40.1 From 01bd905b8229163bcdcaa6ab01c301f60e61d433 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sat, 19 Mar 2022 17:35:54 +0100 Subject: [PATCH 13/19] Prettier --- src/components/Popup.tsx | 1 - src/pages/about-us/index.tsx | 6 +++--- src/pages/news/index.tsx | 4 +++- src/pages/wiki/chronology.tsx | 1 - src/pages/wiki/index.tsx | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/Popup.tsx b/src/components/Popup.tsx index 7cd91b5..12e1110 100644 --- a/src/components/Popup.tsx +++ b/src/components/Popup.tsx @@ -12,7 +12,6 @@ export type PopupProps = { }; export default function Popup(props: PopupProps): JSX.Element { - return (
- + diff --git a/src/pages/news/index.tsx b/src/pages/news/index.tsx index 7aa352a..82c361a 100644 --- a/src/pages/news/index.tsx +++ b/src/pages/news/index.tsx @@ -5,7 +5,9 @@ import AppLayout from "components/AppLayout"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; import { GetPostsPreviewQuery } from "graphql/operations-types"; import { getPostsPreview } from "graphql/operations"; -import ContentPanel, { ContentPanelWidthSizes } from "components/Panels/ContentPanel"; +import ContentPanel, { + ContentPanelWidthSizes, +} from "components/Panels/ContentPanel"; import PostsPreview from "components/News/PostsPreview"; interface NewsProps extends AppStaticProps { diff --git a/src/pages/wiki/chronology.tsx b/src/pages/wiki/chronology.tsx index ed12776..d892db9 100644 --- a/src/pages/wiki/chronology.tsx +++ b/src/pages/wiki/chronology.tsx @@ -91,7 +91,6 @@ export default function Chronology(props: ChronologyProps): JSX.Element { const contentPanel = ( - - + ); -- 2.40.1 From 0f7c04c3937e0f237ccae742110efa41e34a4fdd Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 20 Mar 2022 13:19:27 +0100 Subject: [PATCH 14/19] Added portuguese --- next.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index f8dd901..5d7877c 100644 --- a/next.config.js +++ b/next.config.js @@ -3,7 +3,7 @@ module.exports = { swcMinify: true, reactStrictMode: true, i18n: { - locales: ["en", "fr", "ja", "es"], + locales: ["en", "fr", "ja", "es", "pt-br"], defaultLocale: "en", }, images: { -- 2.40.1 From 54940260e7d8946b317a58a0f57b275410b5228e Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 20 Mar 2022 13:21:30 +0100 Subject: [PATCH 15/19] Added a little message box whenever content is not available in the current language --- src/components/AppLayout.tsx | 5 +- src/components/LanguageSwitcher.tsx | 43 +++++++++++++++++ src/graphql/operation.graphql | 54 +++++++++++++++++++++ src/graphql/operations-types.ts | 74 +++++++++++++++++++++++++++++ src/graphql/operations.ts | 20 ++++++++ src/pages/contents/[slug]/read.tsx | 27 +++++++++-- src/pages/index.tsx | 23 +++++++-- src/pages/news/[slug].tsx | 23 +++++++-- 8 files changed, 253 insertions(+), 16 deletions(-) create mode 100644 src/components/LanguageSwitcher.tsx diff --git a/src/components/AppLayout.tsx b/src/components/AppLayout.tsx index 97fc640..0d713ee 100644 --- a/src/components/AppLayout.tsx +++ b/src/components/AppLayout.tsx @@ -1,7 +1,4 @@ -import { - GetWebsiteInterfaceQuery, - StrapiImage, -} from "graphql/operations-types"; +import { StrapiImage } from "graphql/operations-types"; import MainPanel from "./Panels/MainPanel"; import Head from "next/head"; import { useSwipeable } from "react-swipeable"; diff --git a/src/components/LanguageSwitcher.tsx b/src/components/LanguageSwitcher.tsx new file mode 100644 index 0000000..eb32629 --- /dev/null +++ b/src/components/LanguageSwitcher.tsx @@ -0,0 +1,43 @@ +import { + GetLanguagesQuery, + GetWebsiteInterfaceQuery, +} from "graphql/operations-types"; +import { NextRouter } from "next/router"; +import { prettyLanguage } from "queries/helpers"; +import Button from "./Button"; + +type HorizontalLineProps = { + className?: string; + locales: string[]; + router: NextRouter; + languages: GetLanguagesQuery["languages"]["data"]; + langui: GetWebsiteInterfaceQuery["websiteInterfaces"]["data"][number]["attributes"]; +}; + +export default function HorizontalLine( + props: HorizontalLineProps +): JSX.Element { + const { locales, router } = props; + return ( +
+
+

+ This content is not available in the currently selected language. You + can select one the following languages instead: +

+
+ {locales.map((locale, index) => ( + + ))} +
+
+
+ ); +} diff --git a/src/graphql/operation.graphql b/src/graphql/operation.graphql index b6d3730..0e9f958 100644 --- a/src/graphql/operation.graphql +++ b/src/graphql/operation.graphql @@ -1301,3 +1301,57 @@ query getPostsPreview($language_code: String) { } } } + +query getPostLanguages($slug: String) { + posts(filters: { slug: { eq: $slug } }) { + data { + attributes { + translations { + language { + data { + attributes { + code + } + } + } + } + } + } + } +} + +query getContentLanguages($slug: String) { + contents(filters: { slug: { eq: $slug } }) { + data { + attributes { + text_set { + language { + data { + attributes { + code + } + } + } + } + video_set { + language { + data { + attributes { + code + } + } + } + } + audio_set { + language { + data { + attributes { + code + } + } + } + } + } + } + } +} diff --git a/src/graphql/operations-types.ts b/src/graphql/operations-types.ts index 245677f..4b7f99a 100644 --- a/src/graphql/operations-types.ts +++ b/src/graphql/operations-types.ts @@ -1737,3 +1737,77 @@ export type GetPostsPreviewQuery = { }>; }; }; + +export type GetPostLanguagesQueryVariables = Exact<{ + slug: InputMaybe; +}>; + +export type GetPostLanguagesQuery = { + __typename: "Query"; + posts: { + __typename: "PostEntityResponseCollection"; + data: Array<{ + __typename: "PostEntity"; + attributes: { + __typename: "Post"; + translations: Array<{ + __typename: "ComponentTranslationsPosts"; + language: { + __typename: "LanguageEntityResponse"; + data: { + __typename: "LanguageEntity"; + attributes: { __typename: "Language"; code: string }; + }; + }; + }>; + }; + }>; + }; +}; + +export type GetContentLanguagesQueryVariables = Exact<{ + slug: InputMaybe; +}>; + +export type GetContentLanguagesQuery = { + __typename: "Query"; + contents: { + __typename: "ContentEntityResponseCollection"; + data: Array<{ + __typename: "ContentEntity"; + attributes: { + __typename: "Content"; + text_set: Array<{ + __typename: "ComponentSetsTextSet"; + language: { + __typename: "LanguageEntityResponse"; + data: { + __typename: "LanguageEntity"; + attributes: { __typename: "Language"; code: string }; + }; + }; + }>; + video_set: Array<{ + __typename: "ComponentSetsVideoSet"; + language: { + __typename: "LanguageEntityResponse"; + data: { + __typename: "LanguageEntity"; + attributes: { __typename: "Language"; code: string }; + }; + }; + }>; + audio_set: Array<{ + __typename: "ComponentSetsAudioSet"; + language: { + __typename: "LanguageEntityResponse"; + data: { + __typename: "LanguageEntity"; + attributes: { __typename: "Language"; code: string }; + }; + }; + }>; + }; + }>; + }; +}; diff --git a/src/graphql/operations.ts b/src/graphql/operations.ts index 74a55f2..260b81e 100644 --- a/src/graphql/operations.ts +++ b/src/graphql/operations.ts @@ -3,6 +3,8 @@ import { readFileSync } from "fs"; import { GetChronologyItemsQuery, GetChronologyItemsQueryVariables, + GetContentLanguagesQuery, + GetContentLanguagesQueryVariables, GetContentQuery, GetContentQueryVariables, GetContentsQuery, @@ -23,6 +25,8 @@ import { GetLibraryItemsPreviewQueryVariables, GetLibraryItemsSlugsQuery, GetLibraryItemsSlugsQueryVariables, + GetPostLanguagesQuery, + GetPostLanguagesQueryVariables, GetPostQuery, GetPostQueryVariables, GetPostsPreviewQuery, @@ -168,3 +172,19 @@ export async function getPostsPreview( const query = getQueryFromOperations("getPostsPreview"); return await graphQL(query, JSON.stringify(variables)); } + +export async function getPostLanguages( + variables: GetPostLanguagesQueryVariables +): Promise { + const query = getQueryFromOperations("getPostLanguages"); + console.log(query); + return await graphQL(query, JSON.stringify(variables)); +} + +export async function getContentLanguages( + variables: GetContentLanguagesQueryVariables +): Promise { + const query = getQueryFromOperations("getContentLanguages"); + console.log(query); + return await graphQL(query, JSON.stringify(variables)); +} diff --git a/src/pages/contents/[slug]/read.tsx b/src/pages/contents/[slug]/read.tsx index 25573b2..745e4c3 100644 --- a/src/pages/contents/[slug]/read.tsx +++ b/src/pages/contents/[slug]/read.tsx @@ -1,5 +1,9 @@ import { GetStaticPaths, GetStaticProps } from "next"; -import { getContentsSlugs, getContentText } from "graphql/operations"; +import { + getContentLanguages, + getContentsSlugs, + getContentText, +} from "graphql/operations"; import { GetContentTextQuery } from "graphql/operations-types"; import ContentPanel from "components/Panels/ContentPanel"; import HorizontalLine from "components/HorizontalLine"; @@ -25,15 +29,17 @@ import RecorderChip from "components/RecorderChip"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; import TOC from "components/Markdown/TOC"; import ToolTip from "components/ToolTip"; +import LanguageSwitcher from "components/LanguageSwitcher"; interface ContentReadProps extends AppStaticProps { content: GetContentTextQuery["contents"]["data"][number]["attributes"]; contentId: GetContentTextQuery["contents"]["data"][number]["id"]; + locales: string[]; } export default function ContentRead(props: ContentReadProps): JSX.Element { useTesting(props); - const { langui, content, languages } = props; + const { langui, content, languages, locales } = props; const router = useRouter(); const subPanel = ( @@ -186,8 +192,15 @@ export default function ContentRead(props: ContentReadProps): JSX.Element { - {content.text_set.length > 0 && content.text_set[0].text && ( + {locales.includes(router.locale || "en") ? ( + ) : ( + )}
@@ -235,9 +248,10 @@ export default function ContentRead(props: ContentReadProps): JSX.Element { } export const getStaticProps: GetStaticProps = async (context) => { + const slug = context.params?.slug?.toString() || ""; const content = ( await getContentText({ - slug: context.params?.slug?.toString() || "", + slug: slug, language_code: context.locale || "en", }) ).contents.data[0]; @@ -245,6 +259,11 @@ export const getStaticProps: GetStaticProps = async (context) => { ...(await getAppStaticProps(context)), content: content.attributes, contentId: content.id, + locales: ( + await getContentLanguages({ slug: slug }) + ).contents.data[0].attributes.text_set.map((translation) => { + return translation.language.data.attributes.code; + }), }; return { props: props, diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 0e002ab..e771302 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,7 +1,8 @@ import AppLayout from "components/AppLayout"; +import LanguageSwitcher from "components/LanguageSwitcher"; import Markdawn from "components/Markdown/Markdawn"; import ContentPanel from "components/Panels/ContentPanel"; -import { getPost } from "graphql/operations"; +import { getPost, getPostLanguages } from "graphql/operations"; import { GetPostQuery } from "graphql/operations-types"; import { GetStaticProps } from "next"; import { useRouter } from "next/router"; @@ -10,10 +11,11 @@ import { prettySlug } from "queries/helpers"; interface HomeProps extends AppStaticProps { post: GetPostQuery["posts"]["data"][number]["attributes"]; + locales: string[]; } export default function Home(props: HomeProps): JSX.Element { - const { post } = props; + const { post, locales } = props; const router = useRouter(); const contentPanel = ( @@ -25,8 +27,15 @@ export default function Home(props: HomeProps): JSX.Element { Discover • Analyse • Translate • Archive - {post.translations.length > 0 && ( + {locales.includes(router.locale || "en") ? ( + ) : ( + )} ); @@ -45,14 +54,20 @@ export default function Home(props: HomeProps): JSX.Element { } export const getStaticProps: GetStaticProps = async (context) => { + const slug = "home"; const props: HomeProps = { ...(await getAppStaticProps(context)), post: ( await getPost({ - slug: "home", + slug: slug, language_code: context.locale || "en", }) ).posts.data[0].attributes, + locales: ( + await getPostLanguages({ slug: slug }) + ).posts.data[0].attributes.translations.map((translation) => { + return translation.language.data.attributes.code; + }), }; return { props: props, diff --git a/src/pages/news/[slug].tsx b/src/pages/news/[slug].tsx index 3ee7b54..bafb633 100644 --- a/src/pages/news/[slug].tsx +++ b/src/pages/news/[slug].tsx @@ -2,6 +2,7 @@ import AppLayout from "components/AppLayout"; import Chip from "components/Chip"; import ThumbnailHeader from "components/Content/ThumbnailHeader"; import HorizontalLine from "components/HorizontalLine"; +import LanguageSwitcher from "components/LanguageSwitcher"; import Markdawn from "components/Markdown/Markdawn"; import TOC from "components/Markdown/TOC"; import ReturnButton, { @@ -11,7 +12,7 @@ import ContentPanel from "components/Panels/ContentPanel"; import SubPanel from "components/Panels/SubPanel"; import RecorderChip from "components/RecorderChip"; import ToolTip from "components/ToolTip"; -import { getPost, getPostsSlugs } from "graphql/operations"; +import { getPost, getPostLanguages, getPostsSlugs } from "graphql/operations"; import { GetPostQuery, StrapiImage } from "graphql/operations-types"; import { GetStaticPaths, GetStaticProps } from "next"; import { useRouter } from "next/router"; @@ -21,10 +22,11 @@ import { prettySlug, getStatusDescription } from "queries/helpers"; interface PostProps extends AppStaticProps { post: GetPostQuery["posts"]["data"][number]["attributes"]; postId: GetPostQuery["posts"]["data"][number]["id"]; + locales: string[]; } export default function LibrarySlug(props: PostProps): JSX.Element { - const { post, postId, langui } = props; + const { post, locales, langui } = props; const router = useRouter(); const thumbnail: StrapiImage | undefined = @@ -107,8 +109,15 @@ export default function LibrarySlug(props: PostProps): JSX.Element { - {post.translations.length > 0 && post.translations[0].body && ( + {locales.includes(router.locale || "en") ? ( + ) : ( + )} ); @@ -130,9 +139,10 @@ export default function LibrarySlug(props: PostProps): JSX.Element { } export const getStaticProps: GetStaticProps = async (context) => { + const slug = context.params?.slug?.toString() || ""; const post = ( await getPost({ - slug: context.params?.slug?.toString() || "", + slug: slug, language_code: context.locale || "en", }) ).posts.data[0]; @@ -140,6 +150,11 @@ export const getStaticProps: GetStaticProps = async (context) => { ...(await getAppStaticProps(context)), post: post.attributes, postId: post.id, + locales: ( + await getPostLanguages({ slug: slug }) + ).posts.data[0].attributes.translations.map((translation) => { + return translation.language.data.attributes.code; + }), }; return { props: props, -- 2.40.1 From 3089f2b6fd4439bf4b217da62236627f33391203 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 20 Mar 2022 13:27:51 +0100 Subject: [PATCH 16/19] Added messages to more pages --- src/pages/about-us/accords-handbook.tsx | 23 +++++++++++++++++++---- src/pages/about-us/legality.tsx | 23 +++++++++++++++++++---- src/pages/about-us/sharing-policy.tsx | 21 ++++++++++++++++++--- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/pages/about-us/accords-handbook.tsx b/src/pages/about-us/accords-handbook.tsx index 43946a9..bdfa474 100644 --- a/src/pages/about-us/accords-handbook.tsx +++ b/src/pages/about-us/accords-handbook.tsx @@ -1,4 +1,5 @@ import AppLayout from "components/AppLayout"; +import LanguageSwitcher from "components/LanguageSwitcher"; import Markdawn from "components/Markdown/Markdawn"; import TOC from "components/Markdown/TOC"; import ReturnButton, { @@ -6,7 +7,7 @@ import ReturnButton, { } from "components/PanelComponents/ReturnButton"; import ContentPanel from "components/Panels/ContentPanel"; import SubPanel from "components/Panels/SubPanel"; -import { getPost } from "graphql/operations"; +import { getPost, getPostLanguages } from "graphql/operations"; import { GetPostQuery } from "graphql/operations-types"; import { GetStaticProps } from "next"; import { useRouter } from "next/router"; @@ -15,12 +16,13 @@ import { prettySlug } from "queries/helpers"; interface AccordsHandbookProps extends AppStaticProps { post: GetPostQuery["posts"]["data"][number]["attributes"]; + locales: string[]; } export default function AccordsHandbook( props: AccordsHandbookProps ): JSX.Element { - const { langui, post } = props; + const { langui, post, locales } = props; const router = useRouter(); const subPanel = ( @@ -51,8 +53,15 @@ export default function AccordsHandbook( title={langui.about_us} className="mb-10" /> - {post.translations.length > 0 && ( + {locales.includes(router.locale || "en") ? ( + ) : ( + )} ); @@ -72,14 +81,20 @@ export default function AccordsHandbook( } export const getStaticProps: GetStaticProps = async (context) => { + const slug = "accords-handbook"; const props: AccordsHandbookProps = { ...(await getAppStaticProps(context)), post: ( await getPost({ - slug: "accords-handbook", + slug: slug, language_code: context.locale || "en", }) ).posts.data[0].attributes, + locales: ( + await getPostLanguages({ slug: slug }) + ).posts.data[0].attributes.translations.map((translation) => { + return translation.language.data.attributes.code; + }), }; return { props: props, diff --git a/src/pages/about-us/legality.tsx b/src/pages/about-us/legality.tsx index d773386..f67a28a 100644 --- a/src/pages/about-us/legality.tsx +++ b/src/pages/about-us/legality.tsx @@ -1,4 +1,5 @@ import AppLayout from "components/AppLayout"; +import LanguageSwitcher from "components/LanguageSwitcher"; import Markdawn from "components/Markdown/Markdawn"; import TOC from "components/Markdown/TOC"; import ReturnButton, { @@ -6,7 +7,7 @@ import ReturnButton, { } from "components/PanelComponents/ReturnButton"; import ContentPanel from "components/Panels/ContentPanel"; import SubPanel from "components/Panels/SubPanel"; -import { getPost } from "graphql/operations"; +import { getPost, getPostLanguages } from "graphql/operations"; import { GetPostQuery } from "graphql/operations-types"; import { GetStaticProps } from "next"; import { useRouter } from "next/router"; @@ -15,10 +16,11 @@ import { prettySlug } from "queries/helpers"; interface SiteInfoProps extends AppStaticProps { post: GetPostQuery["posts"]["data"][number]["attributes"]; + locales: string[]; } export default function SiteInformation(props: SiteInfoProps): JSX.Element { - const { langui, post } = props; + const { langui, post, locales } = props; const router = useRouter(); const subPanel = ( @@ -49,8 +51,15 @@ export default function SiteInformation(props: SiteInfoProps): JSX.Element { title={langui.about_us} className="mb-10" /> - {post.translations.length > 0 && ( + {locales.includes(router.locale || "en") ? ( + ) : ( + )} ); @@ -70,14 +79,20 @@ export default function SiteInformation(props: SiteInfoProps): JSX.Element { } export const getStaticProps: GetStaticProps = async (context) => { + const slug = "legality"; const props: SiteInfoProps = { ...(await getAppStaticProps(context)), post: ( await getPost({ - slug: "legality", + slug: slug, language_code: context.locale || "en", }) ).posts.data[0].attributes, + locales: ( + await getPostLanguages({ slug: slug }) + ).posts.data[0].attributes.translations.map((translation) => { + return translation.language.data.attributes.code; + }), }; return { props: props, diff --git a/src/pages/about-us/sharing-policy.tsx b/src/pages/about-us/sharing-policy.tsx index aea24e4..f0a9a25 100644 --- a/src/pages/about-us/sharing-policy.tsx +++ b/src/pages/about-us/sharing-policy.tsx @@ -1,4 +1,5 @@ import AppLayout from "components/AppLayout"; +import LanguageSwitcher from "components/LanguageSwitcher"; import Markdawn from "components/Markdown/Markdawn"; import TOC from "components/Markdown/TOC"; import ReturnButton, { @@ -6,7 +7,7 @@ import ReturnButton, { } from "components/PanelComponents/ReturnButton"; import ContentPanel from "components/Panels/ContentPanel"; import SubPanel from "components/Panels/SubPanel"; -import { getPost } from "graphql/operations"; +import { getPost, getPostLanguages } from "graphql/operations"; import { GetPostQuery } from "graphql/operations-types"; import { GetStaticProps } from "next"; import { useRouter } from "next/router"; @@ -15,10 +16,11 @@ import { prettySlug } from "queries/helpers"; interface SharingPolicyProps extends AppStaticProps { post: GetPostQuery["posts"]["data"][number]["attributes"]; + locales: string[]; } export default function SharingPolicy(props: SharingPolicyProps): JSX.Element { - const { langui, post } = props; + const { langui, post, locales } = props; const router = useRouter(); const subPanel = ( @@ -49,8 +51,15 @@ export default function SharingPolicy(props: SharingPolicyProps): JSX.Element { title={langui.about_us} className="mb-10" /> - {post.translations.length > 0 && ( + {locales.includes(router.locale || "en") ? ( + ) : ( + )} ); @@ -70,6 +79,7 @@ export default function SharingPolicy(props: SharingPolicyProps): JSX.Element { } export const getStaticProps: GetStaticProps = async (context) => { + const slug = "sharing-policy"; const props: SharingPolicyProps = { ...(await getAppStaticProps(context)), post: ( @@ -78,6 +88,11 @@ export const getStaticProps: GetStaticProps = async (context) => { language_code: context.locale || "en", }) ).posts.data[0].attributes, + locales: ( + await getPostLanguages({ slug: slug }) + ).posts.data[0].attributes.translations.map((translation) => { + return translation.language.data.attributes.code; + }), }; return { props: props, -- 2.40.1 From 1b7e425c0e73027dc43fb9c51328b3ffa3aff235 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 20 Mar 2022 13:46:36 +0100 Subject: [PATCH 17/19] Added more translated fields --- src/components/LanguageSwitcher.tsx | 7 ++----- src/components/Panels/MainPanel.tsx | 6 +++--- src/graphql/operation.graphql | 10 ++++++++++ src/graphql/operations-types.ts | 10 ++++++++++ src/pages/about-us/index.tsx | 14 +++++++++----- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/components/LanguageSwitcher.tsx b/src/components/LanguageSwitcher.tsx index eb32629..921879a 100644 --- a/src/components/LanguageSwitcher.tsx +++ b/src/components/LanguageSwitcher.tsx @@ -17,14 +17,11 @@ type HorizontalLineProps = { export default function HorizontalLine( props: HorizontalLineProps ): JSX.Element { - const { locales, router } = props; + const { locales, router, langui } = props; return (
-

- This content is not available in the currently selected language. You - can select one the following languages instead: -

+

{langui.language_switch_message}

{locales.map((locale, index) => (