From 4ffdf32c032585660f546d23b27a42250271f56b Mon Sep 17 00:00:00 2001 From: CanRau Date: Mon, 20 Dec 2021 18:43:39 -0500 Subject: [PATCH] =?UTF-8?q?please=20don't=20ask=20=F0=9F=98=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 2 + .gitignore | 3 +- Dockerfile | 75 + app/app-context.ts | 8 + app/components/age.tsx | 28 + app/components/icons/rss.tsx | 32 + .../illustrations/undraw-bug-fixing.tsx | 617 +++ .../illustrations/undraw-not-found.tsx | 296 ++ app/components/newsletter-form.tsx | 62 + app/components/todos-list.tsx | 212 + app/entry.server.tsx | 121 +- app/root.tsx | 316 +- app/routes/$lang.tsx | 30 + app/routes/$lang/$slug.tsx | 178 +- app/routes/$lang/feed[.]json.tsx | 83 + app/routes/$lang/feed[.]xml.tsx | 171 + app/routes/$lang/index.tsx | 174 + app/routes/$lang/pretty-feed-v3[.]xsl.ts | 179 + app/routes/$lang/sitemap[.]xml.ts | 56 + app/routes/$lang/todos.tsx | 221 + app/routes/demos/about.tsx | 44 - app/routes/demos/about/index.tsx | 22 - app/routes/demos/about/whoa.tsx | 20 - app/routes/demos/actions.tsx | 122 - app/routes/demos/correct.tsx | 3 - app/routes/demos/params.tsx | 55 - app/routes/demos/params/$id.tsx | 114 - app/routes/demos/params/index.tsx | 40 - app/routes/en/windicss-and-remix.mdx | 6 - app/routes/index.tsx | 118 +- app/utils.server.tsx | 15 +- app/utils/compile-mdx.server.ts | 280 +- app/utils/error-responses.ts | 68 + app/utils/get-fly-deploy-version.ts | 42 + app/utils/get-total-path-visits.ts | 45 + app/utils/mdx.server.ts | 87 + config.ts | 15 + content/bookmarks/en.mdx | 41 + .../developer.twitter.com_cookie-banner.png | Bin 0 -> 412482 bytes content/cookie-banners/en.mdx | 29 + .../cookie-banners/gov.uk_cookie-banner.png | Bin 0 -> 389145 bytes content/deno-run-cmd-arguments/en.mdx | 153 + .../en.mdx | 58 + .../en.mdx | 154 + .../en.mdx | 35 +- .../cover_canonical-urls-remix_s.png | Bin 0 -> 29137 bytes .../how-to-add-canonical-url-to-remix/en.mdx | 105 + content/leasot-deno/en.mdx | 240 ++ .../make-everything-dynamic-with-mdx/en.mdx | 23 + .../Bracket-Pair-Colorizer-2_screenshot.png | Bin 0 -> 14587 bytes content/my-vscode-settings/en.mdx | 52 + .../native-bracket-highlighting.png | Bin 0 -> 72526 bytes .../cover_remix-mdx-bundler-images_s.png | Bin 0 -> 97447 bytes content/remix-mdx-bundler-and-images/en.mdx | 97 + content/rss-in-remix/cover_rss-in-remix_s.png | Bin 0 -> 31366 bytes content/rss-in-remix/en.mdx | 645 +++ content/rss-in-remix/styled-xml-feed.png | Bin 0 -> 312354 bytes content/rss-in-remix/unstyled-xml-feed.png | Bin 0 -> 264067 bytes .../tailwind-every-child-except-first/en.mdx | 82 + content/til-issues-with-open-redirects/en.mdx | 38 + content/todo-comment-parsing-in-remix/en.mdx | 389 ++ content/todos-mdx/en.mdx | 22 + content/uses/en.mdx | 36 + content/welcome/en.mdx | 24 +- ...cover_with-or-without-trailing-slash_s.png | Bin 0 -> 37572 bytes content/with-or-without-trailing-slash/en.mdx | 114 + fly.toml | 40 + package-lock.json | 3673 ++++++++++++----- package.json | 59 +- postcss.config.js | 6 +- public/favicon.ico | Bin 16958 -> 40866 bytes remix.config.js | 1 + styles/demos/about.css | 26 - styles/demos/remix.css | 120 - styles/global.css | 98 - styles/tailwind.css | 114 +- tailwind.config.js | 558 +-- types/index.d.ts | 3 + 78 files changed, 8725 insertions(+), 2270 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 app/app-context.ts create mode 100644 app/components/age.tsx create mode 100644 app/components/icons/rss.tsx create mode 100644 app/components/illustrations/undraw-bug-fixing.tsx create mode 100644 app/components/illustrations/undraw-not-found.tsx create mode 100644 app/components/newsletter-form.tsx create mode 100644 app/components/todos-list.tsx create mode 100644 app/routes/$lang.tsx create mode 100644 app/routes/$lang/feed[.]json.tsx create mode 100644 app/routes/$lang/feed[.]xml.tsx create mode 100644 app/routes/$lang/index.tsx create mode 100644 app/routes/$lang/pretty-feed-v3[.]xsl.ts create mode 100644 app/routes/$lang/sitemap[.]xml.ts create mode 100644 app/routes/$lang/todos.tsx delete mode 100644 app/routes/demos/about.tsx delete mode 100644 app/routes/demos/about/index.tsx delete mode 100644 app/routes/demos/about/whoa.tsx delete mode 100644 app/routes/demos/actions.tsx delete mode 100644 app/routes/demos/correct.tsx delete mode 100644 app/routes/demos/params.tsx delete mode 100644 app/routes/demos/params/$id.tsx delete mode 100644 app/routes/demos/params/index.tsx delete mode 100644 app/routes/en/windicss-and-remix.mdx create mode 100644 app/utils/error-responses.ts create mode 100644 app/utils/get-fly-deploy-version.ts create mode 100644 app/utils/get-total-path-visits.ts create mode 100644 app/utils/mdx.server.ts create mode 100644 config.ts create mode 100644 content/bookmarks/en.mdx create mode 100644 content/cookie-banners/developer.twitter.com_cookie-banner.png create mode 100644 content/cookie-banners/en.mdx create mode 100644 content/cookie-banners/gov.uk_cookie-banner.png create mode 100644 content/deno-run-cmd-arguments/en.mdx create mode 100644 content/failed-to-resolve-fs-or-path-in-remix/en.mdx create mode 100644 content/generate-directory-trees-in-your-terminal/en.mdx create mode 100644 content/how-to-add-canonical-url-to-remix/cover_canonical-urls-remix_s.png create mode 100644 content/how-to-add-canonical-url-to-remix/en.mdx create mode 100644 content/leasot-deno/en.mdx create mode 100644 content/make-everything-dynamic-with-mdx/en.mdx create mode 100644 content/my-vscode-settings/Bracket-Pair-Colorizer-2_screenshot.png create mode 100644 content/my-vscode-settings/en.mdx create mode 100644 content/my-vscode-settings/native-bracket-highlighting.png create mode 100644 content/remix-mdx-bundler-and-images/cover_remix-mdx-bundler-images_s.png create mode 100644 content/remix-mdx-bundler-and-images/en.mdx create mode 100644 content/rss-in-remix/cover_rss-in-remix_s.png create mode 100644 content/rss-in-remix/en.mdx create mode 100644 content/rss-in-remix/styled-xml-feed.png create mode 100644 content/rss-in-remix/unstyled-xml-feed.png create mode 100644 content/tailwind-every-child-except-first/en.mdx create mode 100644 content/til-issues-with-open-redirects/en.mdx create mode 100644 content/todo-comment-parsing-in-remix/en.mdx create mode 100644 content/todos-mdx/en.mdx create mode 100644 content/uses/en.mdx create mode 100644 content/with-or-without-trailing-slash/cover_with-or-without-trailing-slash_s.png create mode 100644 content/with-or-without-trailing-slash/en.mdx create mode 100644 fly.toml delete mode 100644 styles/demos/about.css delete mode 100644 styles/demos/remix.css delete mode 100644 styles/global.css create mode 100644 types/index.d.ts diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..97aca2e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.env +node_modules \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6c67ea2..383d7ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ +.env node_modules /.cache /server/build /public/build /build -/app/styles +/app/styles \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3d60f4c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,75 @@ +# base node image +FROM node:16-bullseye-slim as base + +ARG COMMIT_SHA + +# Install openssl for Prisma +RUN apt-get update && apt-get install -y openssl + +# Install all node_modules, including dev dependencies +FROM base as deps + +ARG COMMIT_SHA + +RUN mkdir /app +WORKDIR /app + +ADD package.json package-lock.json ./ +RUN npm install --production=false + +# Setup production node_modules +FROM base as production-deps + +ARG COMMIT_SHA + +RUN mkdir /app +WORKDIR /app + +COPY --from=deps /app/node_modules /app/node_modules +ADD package.json package-lock.json ./ +RUN npm prune --production + +# Build the app +FROM base as build + +ARG COMMIT_SHA +# RUN echo "build stage :>>>>>>>>>>>>>>>> COMMIT_SHA=$COMMIT_SHA" +# RUN echo "build stage :>>>>>>>>>>>>>>>> CSRF_KEY=$CSRF_KEY" + +# todo: KCD sets it only in last step? +ENV NODE_ENV=production + +RUN mkdir /app +WORKDIR /app + +COPY --from=deps /app/node_modules /app/node_modules + +# If we're using Prisma, uncomment to cache the prisma schema +# ADD prisma . +# RUN npx prisma generate + +ADD . . +RUN npm run build + +# Finally, build the production image with minimal footprint +FROM base + +ARG COMMIT_SHA +ENV COMMIT_SHA=$COMMIT_SHA +# ENV CSRF_KEY=$CSRF_KEY + +ENV NODE_ENV=production + +RUN mkdir /app +WORKDIR /app + +COPY --from=production-deps /app/node_modules /app/node_modules + +# Uncomment if using Prisma +# COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma + +COPY --from=build /app/build /app/build +COPY --from=build /app/public /app/public +ADD . . + +CMD ["npm", "run", "start"] diff --git a/app/app-context.ts b/app/app-context.ts new file mode 100644 index 0000000..29179b8 --- /dev/null +++ b/app/app-context.ts @@ -0,0 +1,8 @@ +import { createContext } from "react"; + +export const AppContext = createContext({ + // totalPathVisits: 0, + // path: "", + // setPageViewCountForPath: (path: string, visits: number) => {}, + setPageViewCountForPath: (visits: number) => {}, +}); diff --git a/app/components/age.tsx b/app/components/age.tsx new file mode 100644 index 0000000..51d6c12 --- /dev/null +++ b/app/components/age.tsx @@ -0,0 +1,28 @@ +import differenceInYears from "date-fns/differenceInYears"; + +type Props = { + year: number; + // note: JS Date so month starts at 0=January + month: number; + day: number; +}; + +export const Age = ({ year, month, day }: Props) => { + // based on https://stackoverflow.com/a/62375248/3484824 + // const years = Math.floor( + // (new Date().getTime() - new Date(1988, 0, 17).getTime()) / + // (1000 * 60 * 60 * 24 * 365), + // ); + // done: get birthday from some config or sthg? + const years = differenceInYears(new Date(), new Date(year, month, day)); + // return ; // todo: Research if `