From 76626cdaed291e3cce3a1ea4e298e5c652852fd8 Mon Sep 17 00:00:00 2001 From: xHomu Date: Fri, 20 Sep 2024 16:55:36 -0700 Subject: [PATCH 1/6] dockerfiles make base basic --- Dockerfile | 18 +++++++++++------- fly/core.Dockerfile | 12 ++++++------ fly/custom.Dockerfile | 11 ++++++----- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index a33c7c68..699f2772 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,14 +13,14 @@ ENV IS_HOME $IS_HOME ENV NODE_ENV="production" ENV PORT="3000" +# Throw-away build stage to reduce size of final image +FROM base as build + RUN corepack enable WORKDIR /app COPY package.json yarn.lock ./ COPY ./patches ./patches -# Throw-away build stage to reduce size of final image -FROM base as build - RUN yarn install --frozen-lockfile --production=false COPY . . @@ -38,6 +38,11 @@ RUN yarn run build:custom # Get production dependencies FROM base as production +RUN corepack enable +WORKDIR /app +COPY package.json yarn.lock ./ +COPY ./patches ./patches + RUN yarn install --frozen-lockfile --production=true # Final stage for app image @@ -47,7 +52,8 @@ FROM base as runtime RUN apk add --no-cache supervisor # Copy over built assets for production -COPY supervisord.conf package.json ./ +WORKDIR /app +COPY package.json supervisord.conf ./ COPY --from=production /app/node_modules /app/node_modules COPY --from=custom /app/build /app/build COPY --from=core /app/build /app/build @@ -55,6 +61,4 @@ COPY --from=core /app/public /app/public # Start the server using supervisor EXPOSE 3000 -CMD ["supervisord", "-c", "supervisord.conf"] - - +CMD ["supervisord", "-c", "supervisord.conf"] \ No newline at end of file diff --git a/fly/core.Dockerfile b/fly/core.Dockerfile index cf02d396..dc1a6f50 100644 --- a/fly/core.Dockerfile +++ b/fly/core.Dockerfile @@ -13,14 +13,14 @@ ENV IS_HOME $IS_HOME ENV NODE_ENV="production" ENV PORT="3000" +# Throw-away build stage to reduce size of final image +FROM base as build + RUN corepack enable WORKDIR /app COPY package.json yarn.lock ./ COPY ./patches ./patches -# Throw-away build stage to reduce size of final image -FROM base as build - RUN yarn install --frozen-lockfile --production=false COPY . . @@ -36,12 +36,12 @@ RUN yarn install --frozen-lockfile --production=true FROM base as runtime # Copy over built assets for production -COPY supervisord.conf package.json ./ +WORKDIR /app +COPY package.json ./ COPY --from=production /app/node_modules /app/node_modules COPY --from=build /app/build /app/build COPY --from=build /app/public /app/public # Start the server by default, this can be overwritten at runtime EXPOSE 3000 -CMD ["yarn", "run", "start:core"] - +CMD ["yarn", "run", "start:core"] \ No newline at end of file diff --git a/fly/custom.Dockerfile b/fly/custom.Dockerfile index 6386f5e4..d8336b82 100644 --- a/fly/custom.Dockerfile +++ b/fly/custom.Dockerfile @@ -13,14 +13,14 @@ ENV IS_HOME $IS_HOME ENV NODE_ENV="production" ENV PORT="3000" +# Throw-away build stage to reduce size of final image +FROM base as build + RUN corepack enable WORKDIR /app COPY package.json yarn.lock ./ COPY ./patches ./patches -# Throw-away build stage to reduce size of final image -FROM base as build - RUN yarn install --frozen-lockfile --production=false COPY . . @@ -36,11 +36,12 @@ RUN yarn install --frozen-lockfile --production=true FROM base as runtime # Copy over built assets for production -COPY supervisord.conf package.json ./ +WORKDIR /app +COPY package.json ./ COPY --from=production /app/node_modules /app/node_modules COPY --from=build /app/build /app/build COPY --from=build /app/public /app/public # Start the server by default, this can be overwritten at runtime EXPOSE 4000 -CMD ["yarn", "run", "start:custom"] +CMD ["yarn", "run", "start:custom"] \ No newline at end of file From 6726e7b53befe35e0d3480b53acd3e3ba70559dd Mon Sep 17 00:00:00 2001 From: Nick Winters Date: Fri, 20 Sep 2024 16:57:16 -0700 Subject: [PATCH 2/6] Table of contents rework --- app/components/TableOfContentsTemplate.tsx | 109 ++++++++++++++++++ .../components/SectionTitle.tsx | 29 +++-- .../c_+/_components/TableOfContents.tsx | 101 +--------------- 3 files changed, 128 insertions(+), 111 deletions(-) create mode 100644 app/components/TableOfContentsTemplate.tsx diff --git a/app/components/TableOfContentsTemplate.tsx b/app/components/TableOfContentsTemplate.tsx new file mode 100644 index 00000000..6d403c33 --- /dev/null +++ b/app/components/TableOfContentsTemplate.tsx @@ -0,0 +1,109 @@ +import { Link } from "@remix-run/react"; +import clsx from "clsx"; + +import { Icon } from "~/components/Icon"; +import type { Collection } from "~/db/payload-types"; + +export function TableOfContentsTemplate({ + sections, +}: { + sections: + | Collection["sections"] + | { id: string; slug: string; name: string }[]; +}) { + console.log(sections); + return ( + <> + {sections && sections?.length > 1 && ( +
+
+
+
+ + Table of Contents +
+
+
+ {sections?.map((section) => ( +
+
+
+
+ 1 + ? "rounded-t-lg border-b-0" + : "rounded-lg shadow-sm shadow-zinc-100 dark:shadow-zinc-800/40", + "font-bold pl-2 pr-2.5 mr-3 py-1.5 flex items-center w-full gap-1.5 dark:hover:bg-dark450 border border-color-sub bg-white dark:bg-dark400 hover:bg-zinc-100 ", + )} + > + + {section.name} +
+ + +
+ {section?.subSections && + section?.subSections?.length > 0 ? ( +
1 + ? "rounded-b-lg" + : "rounded-lg", + "border border-color-sub overflow-hidden divide-y divide-color-sub mr-3 ml-[16.5px] tablet:ml-[17px] bg-3-sub shadow-sm shadow-zinc-100 dark:shadow-zinc-800/50", + )} + > + {section.subSections?.map((subSection) => ( + +
+ + {subSection.name} +
+ + + ))} +
+ ) : null} +
+ ))} +
+
+
+ )} + + ); +} diff --git a/app/routes/_site+/c_+/$collectionId_.$entryId/components/SectionTitle.tsx b/app/routes/_site+/c_+/$collectionId_.$entryId/components/SectionTitle.tsx index 8ad97dc5..12220126 100644 --- a/app/routes/_site+/c_+/$collectionId_.$entryId/components/SectionTitle.tsx +++ b/app/routes/_site+/c_+/$collectionId_.$entryId/components/SectionTitle.tsx @@ -5,9 +5,11 @@ import type { Collection } from "~/db/payload-types"; import type { Flatten } from "./Section"; export function SectionTitle({ + customSlug, section, customTitle, }: { + customSlug?: string; section?: Flatten; customTitle?: string; }) { @@ -15,11 +17,14 @@ export function SectionTitle({ if (hasTitle || customTitle) return ( -
- {!customTitle ? ( - +
+ {!customSlug && !section ? ( +

@@ -30,22 +35,22 @@ export function SectionTitle({ />
- {customTitle ?? section?.name} + {customTitle}

- +
) : ( -
+

@@ -53,7 +58,7 @@ export function SectionTitle({

-
+ )}
); diff --git a/app/routes/_site+/c_+/_components/TableOfContents.tsx b/app/routes/_site+/c_+/_components/TableOfContents.tsx index cc77155a..c882013a 100644 --- a/app/routes/_site+/c_+/_components/TableOfContents.tsx +++ b/app/routes/_site+/c_+/_components/TableOfContents.tsx @@ -1,8 +1,6 @@ import type { SerializeFrom } from "@remix-run/node"; -import { Link } from "@remix-run/react"; -import clsx from "clsx"; -import { Icon } from "~/components/Icon"; +import { TableOfContentsTemplate } from "~/components/TableOfContentsTemplate"; import type { Collection } from "~/db/payload-types"; import { useIsStaffOrSiteAdminOrStaffOrOwner } from "~/routes/_auth+/utils/useIsStaffSiteAdminOwner"; import type { loader as entryLoaderType } from "~/routes/_site+/c_+/$collectionId_.$entryId/_entry"; @@ -39,100 +37,5 @@ export function TableOfContents({ const sectionsList = entry ? sectionsWithContent : sections; - return ( - <> - {sectionsList && sectionsList?.length > 1 && ( -
-
-
-
- - Table of Contents -
-
-
- {sectionsList?.map((section) => ( -
-
-
-
- 1 - ? "rounded-t-lg border-b-0" - : "rounded-lg shadow-sm shadow-zinc-100 dark:shadow-zinc-800/40", - "font-bold pl-2 pr-2.5 mr-3 py-1.5 flex items-center w-full gap-1.5 dark:hover:bg-dark450 border border-color-sub bg-white dark:bg-dark400 hover:bg-zinc-100 ", - )} - > - - {section.name} -
- - -
- {section.subSections && - (section.subSections?.length === 1 || - section.subSections?.length === 0) ? null : ( -
1 - ? "rounded-b-lg" - : "rounded-lg", - "border border-color-sub overflow-hidden divide-y divide-color-sub mr-3 ml-[16.5px] tablet:ml-[17px] bg-3-sub shadow-sm shadow-zinc-100 dark:shadow-zinc-800/50", - )} - > - {section.subSections?.map((subSection) => ( - -
- - {/* */} - {subSection.name} -
- - - ))} -
- )} -
- ))} -
-
-
- )} - - ); + return ; } From d432ffc27d2c1d43ef68b0477d4258fea54c025f Mon Sep 17 00:00:00 2001 From: xHomu Date: Fri, 20 Sep 2024 17:00:38 -0700 Subject: [PATCH 3/6] Revert "dockerfiles make base basic" This reverts commit 76626cdaed291e3cce3a1ea4e298e5c652852fd8. --- Dockerfile | 18 +++++++----------- fly/core.Dockerfile | 12 ++++++------ fly/custom.Dockerfile | 11 +++++------ 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index 699f2772..a33c7c68 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,14 +13,14 @@ ENV IS_HOME $IS_HOME ENV NODE_ENV="production" ENV PORT="3000" -# Throw-away build stage to reduce size of final image -FROM base as build - RUN corepack enable WORKDIR /app COPY package.json yarn.lock ./ COPY ./patches ./patches +# Throw-away build stage to reduce size of final image +FROM base as build + RUN yarn install --frozen-lockfile --production=false COPY . . @@ -38,11 +38,6 @@ RUN yarn run build:custom # Get production dependencies FROM base as production -RUN corepack enable -WORKDIR /app -COPY package.json yarn.lock ./ -COPY ./patches ./patches - RUN yarn install --frozen-lockfile --production=true # Final stage for app image @@ -52,8 +47,7 @@ FROM base as runtime RUN apk add --no-cache supervisor # Copy over built assets for production -WORKDIR /app -COPY package.json supervisord.conf ./ +COPY supervisord.conf package.json ./ COPY --from=production /app/node_modules /app/node_modules COPY --from=custom /app/build /app/build COPY --from=core /app/build /app/build @@ -61,4 +55,6 @@ COPY --from=core /app/public /app/public # Start the server using supervisor EXPOSE 3000 -CMD ["supervisord", "-c", "supervisord.conf"] \ No newline at end of file +CMD ["supervisord", "-c", "supervisord.conf"] + + diff --git a/fly/core.Dockerfile b/fly/core.Dockerfile index dc1a6f50..cf02d396 100644 --- a/fly/core.Dockerfile +++ b/fly/core.Dockerfile @@ -13,14 +13,14 @@ ENV IS_HOME $IS_HOME ENV NODE_ENV="production" ENV PORT="3000" -# Throw-away build stage to reduce size of final image -FROM base as build - RUN corepack enable WORKDIR /app COPY package.json yarn.lock ./ COPY ./patches ./patches +# Throw-away build stage to reduce size of final image +FROM base as build + RUN yarn install --frozen-lockfile --production=false COPY . . @@ -36,12 +36,12 @@ RUN yarn install --frozen-lockfile --production=true FROM base as runtime # Copy over built assets for production -WORKDIR /app -COPY package.json ./ +COPY supervisord.conf package.json ./ COPY --from=production /app/node_modules /app/node_modules COPY --from=build /app/build /app/build COPY --from=build /app/public /app/public # Start the server by default, this can be overwritten at runtime EXPOSE 3000 -CMD ["yarn", "run", "start:core"] \ No newline at end of file +CMD ["yarn", "run", "start:core"] + diff --git a/fly/custom.Dockerfile b/fly/custom.Dockerfile index d8336b82..6386f5e4 100644 --- a/fly/custom.Dockerfile +++ b/fly/custom.Dockerfile @@ -13,14 +13,14 @@ ENV IS_HOME $IS_HOME ENV NODE_ENV="production" ENV PORT="3000" -# Throw-away build stage to reduce size of final image -FROM base as build - RUN corepack enable WORKDIR /app COPY package.json yarn.lock ./ COPY ./patches ./patches +# Throw-away build stage to reduce size of final image +FROM base as build + RUN yarn install --frozen-lockfile --production=false COPY . . @@ -36,12 +36,11 @@ RUN yarn install --frozen-lockfile --production=true FROM base as runtime # Copy over built assets for production -WORKDIR /app -COPY package.json ./ +COPY supervisord.conf package.json ./ COPY --from=production /app/node_modules /app/node_modules COPY --from=build /app/build /app/build COPY --from=build /app/public /app/public # Start the server by default, this can be overwritten at runtime EXPOSE 4000 -CMD ["yarn", "run", "start:custom"] \ No newline at end of file +CMD ["yarn", "run", "start:custom"] From 443a4a044e226846e2a5f73cbc4be999e0738ed3 Mon Sep 17 00:00:00 2001 From: xHomu Date: Fri, 20 Sep 2024 17:13:10 -0700 Subject: [PATCH 4/6] Update Dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a33c7c68..43b29755 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,9 +49,10 @@ RUN apk add --no-cache supervisor # Copy over built assets for production COPY supervisord.conf package.json ./ COPY --from=production /app/node_modules /app/node_modules -COPY --from=custom /app/build /app/build COPY --from=core /app/build /app/build COPY --from=core /app/public /app/public +COPY --from=custom /app/build /app/build +COPY --from=custom /app/public /app/public # Start the server using supervisor EXPOSE 3000 From c65978e25ee7aa5c88f38fcb5307312f3f337031 Mon Sep 17 00:00:00 2001 From: Nick Winters Date: Fri, 20 Sep 2024 17:19:29 -0700 Subject: [PATCH 5/6] Add custom page link icon fetcher --- app/routes/_editor+/blocks+/link/_link.tsx | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app/routes/_editor+/blocks+/link/_link.tsx b/app/routes/_editor+/blocks+/link/_link.tsx index f5353e43..a1b3faa7 100644 --- a/app/routes/_editor+/blocks+/link/_link.tsx +++ b/app/routes/_editor+/blocks+/link/_link.tsx @@ -193,6 +193,40 @@ export async function loader({ //Otherwise, return site default: + // Determine if the path is a custom page + try { + const customPageData = await payload.find({ + collection: "customPages", + where: { + site: { + equals: site?.id, + }, + slug: { + equals: pathSection[1], + }, + }, + depth: 1, + overrideAccess: false, + user, + }); + + const customPage = customPageData?.docs[0]; + + if (customPage == undefined) + return { + message: "ok", + }; + + return { + name: customPage?.name, + icon: { + //@ts-ignore + url: customPage?.icon?.url, + }, + }; + } catch (err: unknown) { + payload.logger.error(`${err}`); + } return { message: "ok", }; From 9f4c05b62214fa13855f7e63065189e7182d2680 Mon Sep 17 00:00:00 2001 From: Nick Winters Date: Fri, 20 Sep 2024 21:10:55 -0700 Subject: [PATCH 6/6] add nprogress loader --- app/root.tsx | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + yarn.lock | 17 +++++++++++++++- 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/app/root.tsx b/app/root.tsx index dca22671..dcb466db 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -15,8 +15,11 @@ import { Outlet, Scripts, useLoaderData, + useLocation, + useNavigation, } from "@remix-run/react"; import splideCSS from "@splidejs/splide/dist/css/splide-core.min.css"; +import { useNProgress } from "@tanem/react-nprogress"; import { useTranslation } from "react-i18next"; import reactCropUrl from "react-image-crop/dist/ReactCrop.css"; import rdtStylesheet from "remix-development-tools/index.css"; @@ -145,6 +148,7 @@ function App() { const { i18n } = useTranslation(); const isBot = useIsBot(); const theme = useTheme(); + const navigation = useNavigation(); useChangeLanguage(locale); const { site } = useSiteLoaderData(); @@ -160,6 +164,17 @@ function App() { }, [toast]); const [searchToggle, setSearchToggle] = useState(false); + const [isLoading, setIsLoading] = useState(false); + + useEffect(() => { + // when the state is idle then we can to complete the progress bar + if (navigation.state === "idle") setIsLoading(false); + // and when it's something else it means it's either submitting a form or + // waiting for the loaders of the next location so we start it + else setIsLoading(true); + }, [navigation.state]); + + const location = useLocation(); return ( +
= ({ animationDuration, progress }) => ( +
+
+
+); + +const Progress: React.FC<{ isAnimating: boolean }> = ({ isAnimating }) => { + const { animationDuration, isFinished, progress } = useNProgress({ + isAnimating, + }); + return ( +
+ +
+ ); +}; diff --git a/package.json b/package.json index 28e3a93c..c5ebb0b9 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "@splidejs/react-splide": "^0.7.12", "@stripe/react-stripe-js": "^2.4.0", "@stripe/stripe-js": "^2.2.2", + "@tanem/react-nprogress": "^5.0.51", "@tanstack/match-sorter-utils": "^8.15.1", "@tanstack/react-table": "^8.19.2", "aos": "^3.0.0-beta.6", diff --git a/yarn.lock b/yarn.lock index 0dc9e9a6..7aba6e46 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1069,6 +1069,13 @@ dependencies: regenerator-runtime "^0.14.0" +"@babel/runtime@^7.22.15": + version "7.25.6" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.25.6.tgz#9afc3289f7184d8d7f98b099884c26317b9264d2" + integrity sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ== + dependencies: + regenerator-runtime "^0.14.0" + "@babel/runtime@^7.23.9": version "7.24.0" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.0.tgz#584c450063ffda59697021430cb47101b085951e" @@ -3539,6 +3546,14 @@ resolved "https://registry.yarnpkg.com/@swc/types/-/types-0.1.5.tgz#043b731d4f56a79b4897a3de1af35e75d56bc63a" integrity sha512-myfUej5naTBWnqOCc/MdVOLVjXUXtIA+NpDrDBKJtLLg2shUjBu3cZmB/85RyitKc55+lUUyl7oRfLOvkr2hsw== +"@tanem/react-nprogress@^5.0.51": + version "5.0.51" + resolved "https://registry.yarnpkg.com/@tanem/react-nprogress/-/react-nprogress-5.0.51.tgz#6cbdb52a0a27ecf845f61d809ef6fd45b063662d" + integrity sha512-YxNUCpznuBVA+PhjEzFmxaa1czXgU+5Ojchw5JBK7DQS6SHIgNudpFohWpNBWMu2KWByGJ2OLH2OwbM/XyP18Q== + dependencies: + "@babel/runtime" "^7.22.15" + hoist-non-react-statics "^3.3.2" + "@tanstack/match-sorter-utils@^8.15.1": version "8.15.1" resolved "https://registry.yarnpkg.com/@tanstack/match-sorter-utils/-/match-sorter-utils-8.15.1.tgz#715e028ff43cf79ece10bd5a757047a1016c3bba" @@ -7401,7 +7416,7 @@ hogan.js@^3.0.2: mkdirp "0.3.0" nopt "1.0.10" -hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.1: +hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.1, hoist-non-react-statics@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==