From fec58f2465ef01116d1cfc7954f70e3be3172f5f Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Thu, 23 Feb 2023 20:35:25 -0800 Subject: [PATCH] dep bumps, add pages feature, bug fixes, type improvements --- jest.config.js | 1 + next.config.mjs | 3 + package.json | 10 +- pnpm-lock.yaml | 157 +++++++++-------- .../(auth)/components/auth.module.css | 0 .../{ => (drift)}/(auth)/components/index.tsx | 2 +- .../(auth)/components/query-handler.tsx | 2 +- src/app/{ => (drift)}/(auth)/signin/head.tsx | 0 src/app/{ => (drift)}/(auth)/signin/page.tsx | 0 src/app/{ => (drift)}/(auth)/signup/head.tsx | 0 src/app/{ => (drift)}/(auth)/signup/page.tsx | 0 .../file-dropdown/dropdown.module.css | 0 .../components/file-dropdown/index.tsx | 5 +- .../(posts)/components/preview/index.tsx | 0 .../(posts)/components/preview/katex.min.css | 0 .../components/preview/preview.module.css | 0 .../(posts)/components/tabs/index.tsx | 2 +- .../(posts)/components/tabs/tabs.module.css | 0 .../{ => (drift)}/(posts)/expired/page.tsx | 0 .../new/components/description/index.tsx | 2 +- .../drag-and-drop/drag-and-drop.module.css | 0 .../new/components/drag-and-drop/index.tsx | 0 .../edit-document/document.module.css | 0 .../formatting-icons.module.css | 0 .../edit-document/formatting-icons/index.tsx | 0 .../edit-document/index.tsx | 2 +- .../components/edit-document-list/index.tsx | 0 .../(posts)/new/components/new.tsx | 10 +- .../(posts)/new/components/post.module.css | 0 .../(posts)/new/components/title/index.tsx | 0 .../new/components/title/title.module.css | 0 .../(posts)/new/from/[id]/page.tsx | 14 +- src/app/{ => (drift)}/(posts)/new/head.tsx | 0 src/app/(drift)/(posts)/new/layout.tsx | 3 + src/app/{ => (drift)}/(posts)/new/page.tsx | 2 +- .../(posts)/new/react-datepicker.css | 0 .../components/header/post-buttons/index.tsx | 17 +- .../post-buttons/post-buttons.module.css | 0 .../[id]/components/header/title/index.tsx | 22 +-- .../components/header/title/title.module.css | 0 .../post/[id]/components/post-files/index.tsx | 18 +- .../post-files/password-modal-wrapper.tsx | 14 +- .../view-document/document.module.css | 0 .../post-files/view-document/index.tsx | 83 +++++---- src/app/(drift)/(posts)/post/[id]/context.tsx | 20 +++ .../post/[id]/file/raw/[title]}/route.ts | 0 .../(posts)/post/[id]/get-post.tsx | 8 +- .../{ => (drift)}/(posts)/post/[id]/head.tsx | 0 .../(posts)/post/[id]/layout.module.css | 0 src/app/(drift)/(posts)/post/[id]/layout.tsx | 40 +++++ .../(posts)/post/[id]/loading.tsx | 0 .../{ => (drift)}/(posts)/post/[id]/page.tsx | 12 +- .../admin/components/table.module.css | 0 .../{ => (drift)}/admin/components/tables.tsx | 6 +- src/app/{ => (drift)}/admin/layout.tsx | 5 +- src/app/{ => (drift)}/admin/loading.tsx | 0 src/app/{ => (drift)}/admin/page.tsx | 23 +-- .../{ => (drift)}/author/[username]/page.tsx | 19 +-- src/app/{ => (drift)}/head.tsx | 0 src/app/{ => (drift)}/layout.tsx | 6 +- src/app/{ => (drift)}/mine/head.tsx | 0 src/app/{ => (drift)}/mine/loading.tsx | 0 src/app/{ => (drift)}/mine/page.tsx | 8 +- src/app/{ => (drift)}/page.tsx | 25 ++- src/app/{ => (drift)}/providers.tsx | 6 +- .../components/sections/api-keys.module.css | 0 .../settings/components/sections/api-keys.tsx | 0 .../components/sections/profile.module.css | 0 .../settings/components/sections/profile.tsx | 0 src/app/{ => (drift)}/settings/head.tsx | 0 src/app/{ => (drift)}/settings/layout.tsx | 0 src/app/{ => (drift)}/settings/loading.tsx | 0 src/app/{ => (drift)}/settings/page.tsx | 4 +- src/app/(posts)/new/layout.tsx | 5 - src/app/(posts)/post/[id]/layout.tsx | 57 ------- .../badges/expiration-badge/index.tsx | 4 +- .../badges/visibility-control/index.tsx | 5 +- src/app/components/button/button.module.css | 2 - src/app/components/fade-in/fade.module.css | 10 +- src/app/components/layout/index.tsx | 16 +- src/app/components/layout/page.module.css | 4 + src/app/components/post-list/index.tsx | 8 +- src/app/components/scroll-to-top/index.tsx | 11 +- src/app/components/tooltip/index.tsx | 6 +- src/app/components/tooltip/tooltip.module.css | 30 ++-- src/{ => app}/lib/get-title-for-post-copy.ts | 0 src/app/lib/get-url-friendly-title.tsx | 3 + src/app/pages/[fileId]/[fileTitle]/layout.tsx | 25 +++ src/app/pages/[fileId]/[fileTitle]/page.tsx | 89 ++++++++++ .../[fileId]/[fileTitle]/theme-provider.tsx | 14 ++ src/app/styles/markdown.css | 6 +- src/lib/config.ts | 4 +- src/lib/constants.ts | 9 + src/lib/gist/transform.ts | 7 +- src/lib/server/prisma.ts | 159 +++++++++++++----- src/pages/api/post/index.ts | 4 +- 96 files changed, 645 insertions(+), 384 deletions(-) rename src/app/{ => (drift)}/(auth)/components/auth.module.css (100%) rename src/app/{ => (drift)}/(auth)/components/index.tsx (98%) rename src/app/{ => (drift)}/(auth)/components/query-handler.tsx (92%) rename src/app/{ => (drift)}/(auth)/signin/head.tsx (100%) rename src/app/{ => (drift)}/(auth)/signin/page.tsx (100%) rename src/app/{ => (drift)}/(auth)/signup/head.tsx (100%) rename src/app/{ => (drift)}/(auth)/signup/page.tsx (100%) rename src/app/{ => (drift)}/(posts)/components/file-dropdown/dropdown.module.css (100%) rename src/app/{ => (drift)}/(posts)/components/file-dropdown/index.tsx (94%) rename src/app/{ => (drift)}/(posts)/components/preview/index.tsx (100%) rename src/app/{ => (drift)}/(posts)/components/preview/katex.min.css (100%) rename src/app/{ => (drift)}/(posts)/components/preview/preview.module.css (100%) rename src/app/{ => (drift)}/(posts)/components/tabs/index.tsx (95%) rename src/app/{ => (drift)}/(posts)/components/tabs/tabs.module.css (100%) rename src/app/{ => (drift)}/(posts)/expired/page.tsx (100%) rename src/app/{ => (drift)}/(posts)/new/components/description/index.tsx (89%) rename src/app/{ => (drift)}/(posts)/new/components/drag-and-drop/drag-and-drop.module.css (100%) rename src/app/{ => (drift)}/(posts)/new/components/drag-and-drop/index.tsx (100%) rename src/app/{ => (drift)}/(posts)/new/components/edit-document-list/edit-document/document.module.css (100%) rename src/app/{ => (drift)}/(posts)/new/components/edit-document-list/edit-document/formatting-icons/formatting-icons.module.css (100%) rename src/app/{ => (drift)}/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx (100%) rename src/app/{ => (drift)}/(posts)/new/components/edit-document-list/edit-document/index.tsx (97%) rename src/app/{ => (drift)}/(posts)/new/components/edit-document-list/index.tsx (100%) rename src/app/{ => (drift)}/(posts)/new/components/new.tsx (96%) rename src/app/{ => (drift)}/(posts)/new/components/post.module.css (100%) rename src/app/{ => (drift)}/(posts)/new/components/title/index.tsx (100%) rename src/app/{ => (drift)}/(posts)/new/components/title/title.module.css (100%) rename src/app/{ => (drift)}/(posts)/new/from/[id]/page.tsx (66%) rename src/app/{ => (drift)}/(posts)/new/head.tsx (100%) create mode 100644 src/app/(drift)/(posts)/new/layout.tsx rename src/app/{ => (drift)}/(posts)/new/page.tsx (65%) rename src/app/{ => (drift)}/(posts)/new/react-datepicker.css (100%) rename src/app/{ => (drift)}/(posts)/post/[id]/components/header/post-buttons/index.tsx (86%) rename src/app/{ => (drift)}/(posts)/post/[id]/components/header/post-buttons/post-buttons.module.css (100%) rename src/app/{ => (drift)}/(posts)/post/[id]/components/header/title/index.tsx (76%) rename src/app/{ => (drift)}/(posts)/post/[id]/components/header/title/title.module.css (100%) rename src/app/{ => (drift)}/(posts)/post/[id]/components/post-files/index.tsx (79%) rename src/app/{ => (drift)}/(posts)/post/[id]/components/post-files/password-modal-wrapper.tsx (87%) rename src/app/{ => (drift)}/(posts)/post/[id]/components/post-files/view-document/document.module.css (100%) rename src/app/{ => (drift)}/(posts)/post/[id]/components/post-files/view-document/index.tsx (52%) create mode 100644 src/app/(drift)/(posts)/post/[id]/context.tsx rename src/app/{(posts)/post/[id]/file/raw/[fileId] => (drift)/(posts)/post/[id]/file/raw/[title]}/route.ts (100%) rename src/app/{ => (drift)}/(posts)/post/[id]/get-post.tsx (94%) rename src/app/{ => (drift)}/(posts)/post/[id]/head.tsx (100%) rename src/app/{ => (drift)}/(posts)/post/[id]/layout.module.css (100%) create mode 100644 src/app/(drift)/(posts)/post/[id]/layout.tsx rename src/app/{ => (drift)}/(posts)/post/[id]/loading.tsx (100%) rename src/app/{ => (drift)}/(posts)/post/[id]/page.tsx (55%) rename src/app/{ => (drift)}/admin/components/table.module.css (100%) rename src/app/{ => (drift)}/admin/components/tables.tsx (94%) rename src/app/{ => (drift)}/admin/layout.tsx (79%) rename src/app/{ => (drift)}/admin/loading.tsx (100%) rename src/app/{ => (drift)}/admin/page.tsx (65%) rename src/app/{ => (drift)}/author/[username]/page.tsx (81%) rename src/app/{ => (drift)}/head.tsx (100%) rename src/app/{ => (drift)}/layout.tsx (90%) rename src/app/{ => (drift)}/mine/head.tsx (100%) rename src/app/{ => (drift)}/mine/loading.tsx (100%) rename src/app/{ => (drift)}/mine/page.tsx (75%) rename src/app/{ => (drift)}/page.tsx (80%) rename src/app/{ => (drift)}/providers.tsx (87%) rename src/app/{ => (drift)}/settings/components/sections/api-keys.module.css (100%) rename src/app/{ => (drift)}/settings/components/sections/api-keys.tsx (100%) rename src/app/{ => (drift)}/settings/components/sections/profile.module.css (100%) rename src/app/{ => (drift)}/settings/components/sections/profile.tsx (100%) rename src/app/{ => (drift)}/settings/head.tsx (100%) rename src/app/{ => (drift)}/settings/layout.tsx (100%) rename src/app/{ => (drift)}/settings/loading.tsx (100%) rename src/app/{ => (drift)}/settings/page.tsx (68%) delete mode 100644 src/app/(posts)/new/layout.tsx delete mode 100644 src/app/(posts)/post/[id]/layout.tsx rename src/{ => app}/lib/get-title-for-post-copy.ts (100%) create mode 100644 src/app/lib/get-url-friendly-title.tsx create mode 100644 src/app/pages/[fileId]/[fileTitle]/layout.tsx create mode 100644 src/app/pages/[fileId]/[fileTitle]/page.tsx create mode 100644 src/app/pages/[fileId]/[fileTitle]/theme-provider.tsx diff --git a/jest.config.js b/jest.config.js index 58af244d..d479a225 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,6 +3,7 @@ module.exports = { preset: "ts-jest", testEnvironment: "node", setupFiles: ["/test/setup-tests.ts"], + // TODO: update to app dir moduleNameMapper: { "@lib/(.*)": "/src/lib/$1", "@routes/(.*)": "/src/routes/$1" diff --git a/next.config.mjs b/next.config.mjs index d2320ce2..63e6f42f 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -26,6 +26,9 @@ const nextConfig = { }, env: { NEXT_PUBLIC_DRIFT_URL: process.env.DRIFT_URL + }, + typescript: { + // ignoreBuildErrors: true, } } diff --git a/package.json b/package.json index 4d089be9..ef7bfce2 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ }, "dependencies": { "@next-auth/prisma-adapter": "^1.0.5", - "@next/eslint-plugin-next": "13.1.7-canary.23", - "@next/font": "13.1.7-canary.23", + "@next/eslint-plugin-next": "13.2.1-canary.0", + "@next/font": "13.2.1-canary.0", "@prisma/client": "^4.9.0", "@radix-ui/react-dialog": "^1.0.2", "@radix-ui/react-dropdown-menu": "^2.0.2", @@ -28,7 +28,7 @@ "client-zip": "2.3.0", "jest": "^29.4.1", "lodash.debounce": "^4.0.8", - "next": "13.1.7-canary.23", + "next": "13.2.1-canary.0", "next-auth": "^4.19.2", "next-themes": "^0.2.1", "react": "18.2.0", @@ -45,7 +45,7 @@ "uuid": "^9.0.0" }, "devDependencies": { - "@next/bundle-analyzer": "13.1.6", + "@next/bundle-analyzer": "13.1.7-canary.26", "@types/bcrypt": "^5.0.0", "@types/lodash.debounce": "^4.0.7", "@types/node": "18.11.18", @@ -59,7 +59,7 @@ "cross-env": "7.0.3", "csstype": "^3.1.1", "eslint": "8.33.0", - "eslint-config-next": "13.1.6", + "eslint-config-next": "13.1.7-canary.26", "next-unused": "0.0.6", "prettier": "2.8.3", "prisma": "^4.9.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f31955e4..ded7ff3b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,9 +2,9 @@ lockfileVersion: 5.4 specifiers: '@next-auth/prisma-adapter': ^1.0.5 - '@next/bundle-analyzer': 13.1.6 - '@next/eslint-plugin-next': 13.1.7-canary.23 - '@next/font': 13.1.7-canary.23 + '@next/bundle-analyzer': 13.1.7-canary.26 + '@next/eslint-plugin-next': 13.2.1-canary.0 + '@next/font': 13.2.1-canary.0 '@prisma/client': ^4.9.0 '@radix-ui/react-dialog': ^1.0.2 '@radix-ui/react-dropdown-menu': ^2.0.2 @@ -28,10 +28,10 @@ specifiers: cross-env: 7.0.3 csstype: ^3.1.1 eslint: 8.33.0 - eslint-config-next: 13.1.6 + eslint-config-next: 13.1.7-canary.26 jest: ^29.4.1 lodash.debounce: ^4.0.8 - next: 13.1.7-canary.23 + next: 13.2.1-canary.0 next-auth: ^4.19.2 next-themes: ^0.2.1 next-unused: 0.0.6 @@ -55,8 +55,8 @@ specifiers: dependencies: '@next-auth/prisma-adapter': 1.0.5_77bhi65b6v5jbrzr36rs2ojwe4 - '@next/eslint-plugin-next': 13.1.7-canary.23 - '@next/font': 13.1.7-canary.23 + '@next/eslint-plugin-next': 13.2.1-canary.0 + '@next/font': 13.2.1-canary.0 '@prisma/client': 4.9.0_prisma@4.9.0 '@radix-ui/react-dialog': 1.0.2_5ndqzdd6t4rivxsukjv3i3ak2q '@radix-ui/react-dropdown-menu': 2.0.2_5ndqzdd6t4rivxsukjv3i3ak2q @@ -69,9 +69,9 @@ dependencies: client-zip: 2.3.0 jest: 29.4.1_@types+node@18.11.18 lodash.debounce: 4.0.8 - next: 13.1.7-canary.23_biqbaboplfbrettd7655fr4n2y - next-auth: 4.19.2_de7upave4ddivcfp3gf7tpswk4 - next-themes: 0.2.1_de7upave4ddivcfp3gf7tpswk4 + next: 13.2.1-canary.0_biqbaboplfbrettd7655fr4n2y + next-auth: 4.19.2_avkzbs57los6fogzead7rr4u74 + next-themes: 0.2.1_avkzbs57los6fogzead7rr4u74 react: 18.2.0 react-datepicker: 4.8.0_biqbaboplfbrettd7655fr4n2y react-dom: 18.2.0_react@18.2.0 @@ -89,7 +89,7 @@ optionalDependencies: sharp: 0.31.3 devDependencies: - '@next/bundle-analyzer': 13.1.6 + '@next/bundle-analyzer': 13.1.7-canary.26 '@types/bcrypt': 5.0.0 '@types/lodash.debounce': 4.0.7 '@types/node': 18.11.18 @@ -103,7 +103,7 @@ devDependencies: cross-env: 7.0.3 csstype: 3.1.1 eslint: 8.33.0 - eslint-config-next: 13.1.6_zkdaqh7it7uc4cvz2haft7rc6u + eslint-config-next: 13.1.7-canary.26_zkdaqh7it7uc4cvz2haft7rc6u next-unused: 0.0.6 prettier: 2.8.3 prisma: 4.9.0 @@ -819,11 +819,11 @@ packages: next-auth: ^4 dependencies: '@prisma/client': 4.9.0_prisma@4.9.0 - next-auth: 4.19.2_de7upave4ddivcfp3gf7tpswk4 + next-auth: 4.19.2_avkzbs57los6fogzead7rr4u74 dev: false - /@next/bundle-analyzer/13.1.6: - resolution: {integrity: sha512-rJS9CtLoGT58mL+v2ISKANosFFWP/0YKYByHQ3vTaZrbQP8b1rYRxd2QVMJmnSXaFkiP9URt1XJ6OdGyVq5b6g==} + /@next/bundle-analyzer/13.1.7-canary.26: + resolution: {integrity: sha512-oRAFBr3qEsOC8cwnTWjodckrx1df1pKDSIumvvj9xcp4QeymwDpFdjz2Dp3Manh1Q/kWX+adqNu6fyJUnVDI4A==} dependencies: webpack-bundle-analyzer: 4.7.0 transitivePeerDependencies: @@ -831,28 +831,28 @@ packages: - utf-8-validate dev: true - /@next/env/13.1.7-canary.23: - resolution: {integrity: sha512-7AHpOQHk0xQlLVFjvIaIkAhIsQ5QbIkZRySRigZBWJJ8ycyf6clZe8ileK/sbKdRDKT8O0YeuxtD/kOO8cRMXQ==} + /@next/env/13.2.1-canary.0: + resolution: {integrity: sha512-6e5sszeQUWRFZpy/HXVWs18DKbjErcF/pMKS8pIsknejN1DQPRxNFEI+QuXIf76N+r87K1qR/qWQx4WKQof8Rw==} dev: false - /@next/eslint-plugin-next/13.1.6: - resolution: {integrity: sha512-o7cauUYsXjzSJkay8wKjpKJf2uLzlggCsGUkPu3lP09Pv97jYlekTC20KJrjQKmSv5DXV0R/uks2ZXhqjNkqAw==} + /@next/eslint-plugin-next/13.1.7-canary.26: + resolution: {integrity: sha512-0Cs2jSO+4vmyiWPL3ryMRGIl2+UZ+rV9TFaxzGLZUfN2yQKodR2Ilt3CWmRBFNRJr6MV2N+BIdIQ5MPy/TBeRg==} dependencies: glob: 7.1.7 dev: true - /@next/eslint-plugin-next/13.1.7-canary.23: - resolution: {integrity: sha512-8Se+LIQ4iOKxelhq0Va14PXkOm2UFgPQPJJqmN8GojiiY3gVKB2WJHsqDDu6o9dPNt7OgemLtQePcJH2barw5Q==} + /@next/eslint-plugin-next/13.2.1-canary.0: + resolution: {integrity: sha512-OwJgZrTGj/WovColJHOUd2RB+2uju12cYL2oL5CnyNTz999GJ/z/esghfCAqL5fh4YaiQqlZCRJEbbymTsiU0Q==} dependencies: glob: 7.1.7 dev: false - /@next/font/13.1.7-canary.23: - resolution: {integrity: sha512-y5pZjah3b5n2X1yMMAImPwAMi2hFY6Maip76R6+VzLjak+pNMB5jF72ieZoRsibGxt+efCoWOWIkh5s7ZO8YrA==} + /@next/font/13.2.1-canary.0: + resolution: {integrity: sha512-ByXy8uwtXMihrIKmkcDZxvLgfE5i5Y0kowcg+vATw+b7ukzUzlesI+65VWTo2AHVdtrBPGAdAjyJJTNvr/q4nQ==} dev: false - /@next/swc-android-arm-eabi/13.1.7-canary.23: - resolution: {integrity: sha512-LxaoUF1bqi0hPrOci7RChuOg4oJA2IHiC6SviAlSTzWUgi3eJuigvfptTylO1ElBX4MMSJ5mqpq1h5fNQIg5/A==} + /@next/swc-android-arm-eabi/13.2.1-canary.0: + resolution: {integrity: sha512-irsC3EdtmroNaHrKeqZDJTcQ15wrTWp5JJ8IIMJ6GvW/vhVENk+unnVoxD4BQLmgelCbzi7udusISDCkUUWCkg==} engines: {node: '>= 10'} cpu: [arm] os: [android] @@ -860,8 +860,8 @@ packages: dev: false optional: true - /@next/swc-android-arm64/13.1.7-canary.23: - resolution: {integrity: sha512-gsJyRGzJlBLZNNfpPwn1T1MgeT3p/Ztx3lMuc37+v+sMjgegWZy7h5HbtTp7IT+y4DAwknNcSyLIidH88qj9lA==} + /@next/swc-android-arm64/13.2.1-canary.0: + resolution: {integrity: sha512-3AyZ4THkuamCyOhFkrqFY38IMI+YFmxomOcFHK+67hrqfHQRkH0boL15SnHAzURlAeruI/Mw9/PuYshYXn3Usg==} engines: {node: '>= 10'} cpu: [arm64] os: [android] @@ -869,8 +869,8 @@ packages: dev: false optional: true - /@next/swc-darwin-arm64/13.1.7-canary.23: - resolution: {integrity: sha512-29HDi1EQkNaiNU0yJDikIV4jAJvs52TeGqTDf9tIkHFOAvmAF50mGbaL2urcRhy1fFvubLEx3JHWV6pAobjq3g==} + /@next/swc-darwin-arm64/13.2.1-canary.0: + resolution: {integrity: sha512-CN5e/C9WLGa8EdAmnndGzKh14ALfMHwjoRZYHBfFmM1Z+SArz89VrXeOmAMVgpcANBNC4ShvXp4rIUD9PveDQA==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -878,8 +878,8 @@ packages: dev: false optional: true - /@next/swc-darwin-x64/13.1.7-canary.23: - resolution: {integrity: sha512-iWU/5+myA89I25AtLHeZP03jqUh9OfUF67oQ1ZiDNcKZAEDGqYgwqVeiUbU6rBhX483YwZOAF+iUpYefV9FLQQ==} + /@next/swc-darwin-x64/13.2.1-canary.0: + resolution: {integrity: sha512-eP7hKzI84MrG54M3207pynGmJHqf2V6Ex0CXpht0WSMrrv7G6W9iHyLPqk18AgxzgjA5QH4lDP+FpTaoDmpdkg==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -887,8 +887,8 @@ packages: dev: false optional: true - /@next/swc-freebsd-x64/13.1.7-canary.23: - resolution: {integrity: sha512-IuJljewmj7BNJI9qsLXzJZBC1qU7adif0Pcg2ww5Al6l8RviGy6aBWdMgt65tHTGlUqxHhLg7mW5jT2bUw1Bcw==} + /@next/swc-freebsd-x64/13.2.1-canary.0: + resolution: {integrity: sha512-rloppA9VtxDFruDxMQJqrISwKzOip9/1hksljlXTBg+/fu2dJyufuARwhfksDNH3fBT0fQC10esFO+WjhLEp7g==} engines: {node: '>= 10'} cpu: [x64] os: [freebsd] @@ -896,8 +896,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm-gnueabihf/13.1.7-canary.23: - resolution: {integrity: sha512-d1I0WY/L4RW4pQcDihWjMo+s90hv9c83lzDi1fsjhzKMJnHKyOcZKc2tXB6OvHW67y6PL6bgpPcqysmS4txwjA==} + /@next/swc-linux-arm-gnueabihf/13.2.1-canary.0: + resolution: {integrity: sha512-Fb0d7znHY3RlaJFCc07X+x3NGQw3Sp0UOsCOtalG2LSgMKFTt0dMc47WBZez+ratWI7dc6B3H8kmsgntBd4Skw==} engines: {node: '>= 10'} cpu: [arm] os: [linux] @@ -905,8 +905,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-gnu/13.1.7-canary.23: - resolution: {integrity: sha512-zMaepi3ZZvPserWz34ZU9JKmZPnUn/1HKEe6oNuxkHSDIqR6RM2DcUIj5mwsUdQzCAHJs8ZbLpoAtiOj7x+Ipg==} + /@next/swc-linux-arm64-gnu/13.2.1-canary.0: + resolution: {integrity: sha512-ATkCdBfHpTtB+7VWgsib2O98sUAa9vyB7uyHTFDWPMB9qTnTXMUfPoYxFJmYXrjwB/xoW97AKrB3FGxMM+swHw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -914,8 +914,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-musl/13.1.7-canary.23: - resolution: {integrity: sha512-4bMTuoCQ5cf+6O7tIP//I4FF5o4crfRq7DdUTXoZvlF81xjlnI+gCRiHU8AllUryRhci+r4kM9/2m3GQkGQdqA==} + /@next/swc-linux-arm64-musl/13.2.1-canary.0: + resolution: {integrity: sha512-2x2i0dgcyhE9wycHYLAZiiHkQlzambV0qdjsG7DqQhc23UhVvkqG6dB9PHPFrkxMFPq2QDLpYGlKF9sdnnEQbw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -923,8 +923,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-gnu/13.1.7-canary.23: - resolution: {integrity: sha512-plovQsBsXdJUaQYx7aQHiUlYtxgawlp+1a9VX6CPJPM15HR91KmJsmdfI+JW1fVbV4x+N0TDARzdGSHKQNLAHQ==} + /@next/swc-linux-x64-gnu/13.2.1-canary.0: + resolution: {integrity: sha512-nRQfotbWl4V9sIS+nx4ZXtJxe8/+naeUrJSoD+Wi9PrIyF3uuLE+xi1WMHS5RhGydyduvFSyIjQO2qGzZ0Lhsw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -932,8 +932,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-musl/13.1.7-canary.23: - resolution: {integrity: sha512-0b9BiJ2eOFypCa41gEhURxD9borWGfXBb3AnhxwmUnMAanhZZSVutBCGjxqvki3qbTPCMUv6dVUaKXw+26ylPg==} + /@next/swc-linux-x64-musl/13.2.1-canary.0: + resolution: {integrity: sha512-hdM2Cds8yppGSzql2A4tCYdzjVheDh/Ei45GOz94gshO95u7SSS9UQNTaOKZTWOUfRnZYZrEbAVMhDxz10qqdQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -941,8 +941,8 @@ packages: dev: false optional: true - /@next/swc-win32-arm64-msvc/13.1.7-canary.23: - resolution: {integrity: sha512-psVpG4pmJHrqjXMfKcXyRNO5t18tpee4pZAuTesu8DfRd+fPqg1CwB1Hp8qBxG9c80loCoQMlKFiH5nPFAvv+g==} + /@next/swc-win32-arm64-msvc/13.2.1-canary.0: + resolution: {integrity: sha512-2SkgCWZbDLBgKbgJ+slVpqQLNwOzp2/ja2C8nNzwUbDB4cbD9fTyWrUngZBgg8J1OaP5KR7qHOQ8JQoHqiTOjA==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -950,8 +950,8 @@ packages: dev: false optional: true - /@next/swc-win32-ia32-msvc/13.1.7-canary.23: - resolution: {integrity: sha512-5ZW5+QoI9yibjUPcHfh/uBjB5ubcsKoD45LNbxsxWGOl9c/tXp4zvhqIEtZ57SWajdZZiuKZ0I92MGxgiDwYfw==} + /@next/swc-win32-ia32-msvc/13.2.1-canary.0: + resolution: {integrity: sha512-1j1BJ2wtzDnbn6uOUPsPhOgjIWESr8TE7aLUAlxtTYgsrYdPYxe4uowa9M04mEw6UxZHatrrOA6zvTVoFUtB8g==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -959,8 +959,8 @@ packages: dev: false optional: true - /@next/swc-win32-x64-msvc/13.1.7-canary.23: - resolution: {integrity: sha512-+90NgEZmVqLtQ+adKtZxz67XJvjF/gESaSH8Zt96ccNH9lzoZsSyX/SYHwNJQFikiBCNn0SMeAZHIlsY5dEbqQ==} + /@next/swc-win32-x64-msvc/13.2.1-canary.0: + resolution: {integrity: sha512-87QjJxWWYIPKBx/FoaqEd2bxPFBdTUZ6OdEnCeuBW2XjN6qZpwL1H2dIEvh6EXJMjQYW/DAhOqgr9cvpw9fu+Q==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -1955,7 +1955,7 @@ packages: dependencies: '@types/react': 18.0.27 react: 18.2.0 - tslib: 2.4.1 + tslib: 2.5.0 dev: false /aria-hidden/1.2.2_3stiutgnnbnfnf3uowm5cip22i: @@ -2970,8 +2970,8 @@ packages: source-map: 0.6.1 dev: true - /eslint-config-next/13.1.6_zkdaqh7it7uc4cvz2haft7rc6u: - resolution: {integrity: sha512-0cg7h5wztg/SoLAlxljZ0ZPUQ7i6QKqRiP4M2+MgTZtxWwNKb2JSwNc18nJ6/kXBI6xYvPraTbQSIhAuVw6czw==} + /eslint-config-next/13.1.7-canary.26_zkdaqh7it7uc4cvz2haft7rc6u: + resolution: {integrity: sha512-pKLrCNiKO4uekzZJaIXthsasvlEzSiGQLsO2I2FPr+sQAjY18UhY3jl2HZznU/vbk5GHVRKs5ibrye/29KDtbQ==} peerDependencies: eslint: ^7.23.0 || ^8.0.0 typescript: '>=3.3.1' @@ -2979,7 +2979,7 @@ packages: typescript: optional: true dependencies: - '@next/eslint-plugin-next': 13.1.6 + '@next/eslint-plugin-next': 13.1.7-canary.26 '@rushstack/eslint-patch': 1.2.0 '@typescript-eslint/parser': 5.49.0_zkdaqh7it7uc4cvz2haft7rc6u eslint: 8.33.0 @@ -3367,7 +3367,7 @@ packages: resolution: {integrity: sha512-QlZ5yJC0VxHxQQsQhXvBaC7VRJ2uaxTf+Tfpu4Z/OcVQJVpZO+DGU0rkoVW5ce2SccxugvpBJoMvUs59iILYdw==} engines: {node: '>= 12'} dependencies: - tslib: 2.4.1 + tslib: 2.5.0 dev: false /filing-cabinet/3.3.0: @@ -5473,7 +5473,7 @@ packages: dev: true optional: true - /next-auth/4.19.2_de7upave4ddivcfp3gf7tpswk4: + /next-auth/4.19.2_avkzbs57los6fogzead7rr4u74: resolution: {integrity: sha512-6V2YG3IJQVhgCAH7mvT3yopTW92gMdUrcwGX7NQ0dCreT/+axGua/JmVdarjec0C/oJukKpIYRgjMlV+L5ZQOQ==} peerDependencies: next: ^12.2.5 || ^13 @@ -5488,7 +5488,7 @@ packages: '@panva/hkdf': 1.0.2 cookie: 0.5.0 jose: 4.11.0 - next: 13.1.7-canary.23_biqbaboplfbrettd7655fr4n2y + next: 13.2.1-canary.0_biqbaboplfbrettd7655fr4n2y oauth: 0.9.15 openid-client: 5.3.0 preact: 10.11.2 @@ -5498,14 +5498,14 @@ packages: uuid: 8.3.2 dev: false - /next-themes/0.2.1_de7upave4ddivcfp3gf7tpswk4: + /next-themes/0.2.1_avkzbs57los6fogzead7rr4u74: resolution: {integrity: sha512-B+AKNfYNIzh0vqQQKqQItTS8evEouKD7H5Hj3kmuPERwddR2TxvDSFZuTj6T7Jfn1oyeUyJMydPl1Bkxkh0W7A==} peerDependencies: next: '*' react: '*' react-dom: '*' dependencies: - next: 13.1.7-canary.23_biqbaboplfbrettd7655fr4n2y + next: 13.2.1-canary.0_biqbaboplfbrettd7655fr4n2y react: 18.2.0 react-dom: 18.2.0_react@18.2.0 dev: false @@ -5521,17 +5521,20 @@ packages: - supports-color dev: true - /next/13.1.7-canary.23_biqbaboplfbrettd7655fr4n2y: - resolution: {integrity: sha512-kUgSfsX+f09h8ULeqitJmUff6RPkhZq2xA2X6hSnFMrZEAjxeuAiGDdK6dZXNiuuQDHTXnZOvovupq05pf2z2w==} + /next/13.2.1-canary.0_biqbaboplfbrettd7655fr4n2y: + resolution: {integrity: sha512-4dXz9jinbUmxOCnXxDPxcFHmwhR+YDCLRP0kiYUpu1GiTlTYbfHAb0HosmA58ZL76W1tmqS6x8/3qkiDNtZWrg==} engines: {node: '>=14.6.0'} hasBin: true peerDependencies: + '@opentelemetry/api': ^1.4.0 fibers: '>= 3.1.0' node-sass: ^6.0.0 || ^7.0.0 react: ^18.2.0 react-dom: ^18.2.0 sass: ^1.3.0 peerDependenciesMeta: + '@opentelemetry/api': + optional: true fibers: optional: true node-sass: @@ -5539,7 +5542,7 @@ packages: sass: optional: true dependencies: - '@next/env': 13.1.7-canary.23 + '@next/env': 13.2.1-canary.0 '@swc/helpers': 0.4.14 caniuse-lite: 1.0.30001449 postcss: 8.4.14 @@ -5547,19 +5550,19 @@ packages: react-dom: 18.2.0_react@18.2.0 styled-jsx: 5.1.1_react@18.2.0 optionalDependencies: - '@next/swc-android-arm-eabi': 13.1.7-canary.23 - '@next/swc-android-arm64': 13.1.7-canary.23 - '@next/swc-darwin-arm64': 13.1.7-canary.23 - '@next/swc-darwin-x64': 13.1.7-canary.23 - '@next/swc-freebsd-x64': 13.1.7-canary.23 - '@next/swc-linux-arm-gnueabihf': 13.1.7-canary.23 - '@next/swc-linux-arm64-gnu': 13.1.7-canary.23 - '@next/swc-linux-arm64-musl': 13.1.7-canary.23 - '@next/swc-linux-x64-gnu': 13.1.7-canary.23 - '@next/swc-linux-x64-musl': 13.1.7-canary.23 - '@next/swc-win32-arm64-msvc': 13.1.7-canary.23 - '@next/swc-win32-ia32-msvc': 13.1.7-canary.23 - '@next/swc-win32-x64-msvc': 13.1.7-canary.23 + '@next/swc-android-arm-eabi': 13.2.1-canary.0 + '@next/swc-android-arm64': 13.2.1-canary.0 + '@next/swc-darwin-arm64': 13.2.1-canary.0 + '@next/swc-darwin-x64': 13.2.1-canary.0 + '@next/swc-freebsd-x64': 13.2.1-canary.0 + '@next/swc-linux-arm-gnueabihf': 13.2.1-canary.0 + '@next/swc-linux-arm64-gnu': 13.2.1-canary.0 + '@next/swc-linux-arm64-musl': 13.2.1-canary.0 + '@next/swc-linux-x64-gnu': 13.2.1-canary.0 + '@next/swc-linux-x64-musl': 13.2.1-canary.0 + '@next/swc-win32-arm64-msvc': 13.2.1-canary.0 + '@next/swc-win32-ia32-msvc': 13.2.1-canary.0 + '@next/swc-win32-x64-msvc': 13.2.1-canary.0 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros @@ -6288,7 +6291,7 @@ packages: react: 18.2.0 react-remove-scroll-bar: 2.3.4_3stiutgnnbnfnf3uowm5cip22i react-style-singleton: 2.2.1_3stiutgnnbnfnf3uowm5cip22i - tslib: 2.4.1 + tslib: 2.5.0 use-callback-ref: 1.3.0_3stiutgnnbnfnf3uowm5cip22i use-sidecar: 1.1.2_3stiutgnnbnfnf3uowm5cip22i dev: false @@ -7143,10 +7146,6 @@ packages: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true - /tslib/2.4.1: - resolution: {integrity: sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==} - dev: false - /tslib/2.5.0: resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==} diff --git a/src/app/(auth)/components/auth.module.css b/src/app/(drift)/(auth)/components/auth.module.css similarity index 100% rename from src/app/(auth)/components/auth.module.css rename to src/app/(drift)/(auth)/components/auth.module.css diff --git a/src/app/(auth)/components/index.tsx b/src/app/(drift)/(auth)/components/index.tsx similarity index 98% rename from src/app/(auth)/components/index.tsx rename to src/app/(drift)/(auth)/components/index.tsx index ee23a882..28d7d5fe 100644 --- a/src/app/(auth)/components/index.tsx +++ b/src/app/(drift)/(auth)/components/index.tsx @@ -2,7 +2,7 @@ import { startTransition, Suspense, useState } from "react" import styles from "./auth.module.css" -import Link from "../../components/link" +import Link from "../../../components/link" import { signIn } from "next-auth/react" import Input from "@components/input" import Button from "@components/button" diff --git a/src/app/(auth)/components/query-handler.tsx b/src/app/(drift)/(auth)/components/query-handler.tsx similarity index 92% rename from src/app/(auth)/components/query-handler.tsx rename to src/app/(drift)/(auth)/components/query-handler.tsx index 9864b5c5..e5f1f2d0 100644 --- a/src/app/(auth)/components/query-handler.tsx +++ b/src/app/(drift)/(auth)/components/query-handler.tsx @@ -9,7 +9,7 @@ export function ErrorQueryParamsHandler() { const { setToast } = useToasts() useEffect(() => { - if (queryParams.get("error")) { + if (queryParams?.get("error")) { setToast({ message: queryParams.get("error") as string, type: "error" diff --git a/src/app/(auth)/signin/head.tsx b/src/app/(drift)/(auth)/signin/head.tsx similarity index 100% rename from src/app/(auth)/signin/head.tsx rename to src/app/(drift)/(auth)/signin/head.tsx diff --git a/src/app/(auth)/signin/page.tsx b/src/app/(drift)/(auth)/signin/page.tsx similarity index 100% rename from src/app/(auth)/signin/page.tsx rename to src/app/(drift)/(auth)/signin/page.tsx diff --git a/src/app/(auth)/signup/head.tsx b/src/app/(drift)/(auth)/signup/head.tsx similarity index 100% rename from src/app/(auth)/signup/head.tsx rename to src/app/(drift)/(auth)/signup/head.tsx diff --git a/src/app/(auth)/signup/page.tsx b/src/app/(drift)/(auth)/signup/page.tsx similarity index 100% rename from src/app/(auth)/signup/page.tsx rename to src/app/(drift)/(auth)/signup/page.tsx diff --git a/src/app/(posts)/components/file-dropdown/dropdown.module.css b/src/app/(drift)/(posts)/components/file-dropdown/dropdown.module.css similarity index 100% rename from src/app/(posts)/components/file-dropdown/dropdown.module.css rename to src/app/(drift)/(posts)/components/file-dropdown/dropdown.module.css diff --git a/src/app/(posts)/components/file-dropdown/index.tsx b/src/app/(drift)/(posts)/components/file-dropdown/index.tsx similarity index 94% rename from src/app/(posts)/components/file-dropdown/index.tsx rename to src/app/(drift)/(posts)/components/file-dropdown/index.tsx index e6a67e0d..5c0448d0 100644 --- a/src/app/(posts)/components/file-dropdown/index.tsx +++ b/src/app/(drift)/(posts)/components/file-dropdown/index.tsx @@ -59,7 +59,10 @@ function FileDropdown({ return ( - +
) diff --git a/src/app/(posts)/new/components/drag-and-drop/drag-and-drop.module.css b/src/app/(drift)/(posts)/new/components/drag-and-drop/drag-and-drop.module.css similarity index 100% rename from src/app/(posts)/new/components/drag-and-drop/drag-and-drop.module.css rename to src/app/(drift)/(posts)/new/components/drag-and-drop/drag-and-drop.module.css diff --git a/src/app/(posts)/new/components/drag-and-drop/index.tsx b/src/app/(drift)/(posts)/new/components/drag-and-drop/index.tsx similarity index 100% rename from src/app/(posts)/new/components/drag-and-drop/index.tsx rename to src/app/(drift)/(posts)/new/components/drag-and-drop/index.tsx diff --git a/src/app/(posts)/new/components/edit-document-list/edit-document/document.module.css b/src/app/(drift)/(posts)/new/components/edit-document-list/edit-document/document.module.css similarity index 100% rename from src/app/(posts)/new/components/edit-document-list/edit-document/document.module.css rename to src/app/(drift)/(posts)/new/components/edit-document-list/edit-document/document.module.css diff --git a/src/app/(posts)/new/components/edit-document-list/edit-document/formatting-icons/formatting-icons.module.css b/src/app/(drift)/(posts)/new/components/edit-document-list/edit-document/formatting-icons/formatting-icons.module.css similarity index 100% rename from src/app/(posts)/new/components/edit-document-list/edit-document/formatting-icons/formatting-icons.module.css rename to src/app/(drift)/(posts)/new/components/edit-document-list/edit-document/formatting-icons/formatting-icons.module.css diff --git a/src/app/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx b/src/app/(drift)/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx similarity index 100% rename from src/app/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx rename to src/app/(drift)/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx diff --git a/src/app/(posts)/new/components/edit-document-list/edit-document/index.tsx b/src/app/(drift)/(posts)/new/components/edit-document-list/edit-document/index.tsx similarity index 97% rename from src/app/(posts)/new/components/edit-document-list/edit-document/index.tsx rename to src/app/(drift)/(posts)/new/components/edit-document-list/edit-document/index.tsx index 8905abfe..44b13542 100644 --- a/src/app/(posts)/new/components/edit-document-list/edit-document/index.tsx +++ b/src/app/(drift)/(posts)/new/components/edit-document-list/edit-document/index.tsx @@ -2,7 +2,7 @@ import { ChangeEvent, ClipboardEvent, useCallback } from "react" import styles from "./document.module.css" import Button from "@components/button" import Input from "@components/input" -import DocumentTabs from "src/app/(posts)/components/tabs" +import DocumentTabs from "src/app/(drift)/(posts)/components/tabs" import { Trash } from "react-feather" type Props = { diff --git a/src/app/(posts)/new/components/edit-document-list/index.tsx b/src/app/(drift)/(posts)/new/components/edit-document-list/index.tsx similarity index 100% rename from src/app/(posts)/new/components/edit-document-list/index.tsx rename to src/app/(drift)/(posts)/new/components/edit-document-list/index.tsx diff --git a/src/app/(posts)/new/components/new.tsx b/src/app/(drift)/(posts)/new/components/new.tsx similarity index 96% rename from src/app/(posts)/new/components/new.tsx rename to src/app/(drift)/(posts)/new/components/new.tsx index 5015cc8c..77a6139a 100644 --- a/src/app/(posts)/new/components/new.tsx +++ b/src/app/(drift)/(posts)/new/components/new.tsx @@ -6,10 +6,10 @@ import generateUUID from "@lib/generate-uuid" import styles from "./post.module.css" import EditDocumentList from "./edit-document-list" import { ChangeEvent } from "react" -import getTitleForPostCopy from "@lib/get-title-for-post-copy" +import getTitleForPostCopy from "src/app/lib/get-title-for-post-copy" import Description from "./description" import { PostWithFiles } from "@lib/server/prisma" -import PasswordModal from "../../../components/password-modal" +import PasswordModal from "../../../../components/password-modal" import Title from "./title" import FileDropzone from "./drag-and-drop" import Button from "@components/button" @@ -35,16 +35,14 @@ export type Document = { } function Post({ - initialPost: stringifiedInitialPost, + initialPost, newPostParent }: { - initialPost?: string + initialPost?: PostWithFiles newPostParent?: string }): JSX.Element | null { const { isAuthenticated } = useSessionSWR() - const parsedPost = JSON.parse(stringifiedInitialPost || "{}") as PostWithFiles - const initialPost = parsedPost?.id ? parsedPost : null const { setToast } = useToasts() const router = useRouter() const [title, setTitle] = useState( diff --git a/src/app/(posts)/new/components/post.module.css b/src/app/(drift)/(posts)/new/components/post.module.css similarity index 100% rename from src/app/(posts)/new/components/post.module.css rename to src/app/(drift)/(posts)/new/components/post.module.css diff --git a/src/app/(posts)/new/components/title/index.tsx b/src/app/(drift)/(posts)/new/components/title/index.tsx similarity index 100% rename from src/app/(posts)/new/components/title/index.tsx rename to src/app/(drift)/(posts)/new/components/title/index.tsx diff --git a/src/app/(posts)/new/components/title/title.module.css b/src/app/(drift)/(posts)/new/components/title/title.module.css similarity index 100% rename from src/app/(posts)/new/components/title/title.module.css rename to src/app/(drift)/(posts)/new/components/title/title.module.css diff --git a/src/app/(posts)/new/from/[id]/page.tsx b/src/app/(drift)/(posts)/new/from/[id]/page.tsx similarity index 66% rename from src/app/(posts)/new/from/[id]/page.tsx rename to src/app/(drift)/(posts)/new/from/[id]/page.tsx index e7c2562a..2b27bc32 100644 --- a/src/app/(posts)/new/from/[id]/page.tsx +++ b/src/app/(drift)/(posts)/new/from/[id]/page.tsx @@ -1,6 +1,10 @@ import NewPost from "../../components/new" import { notFound, redirect } from "next/navigation" -import { getPostById } from "@lib/server/prisma" +import { + getPostById, + serverPostToClientPost, + ServerPostWithFiles +} from "@lib/server/prisma" import { getSession } from "@lib/server/session" async function NewFromExisting({ @@ -21,7 +25,7 @@ async function NewFromExisting({ return notFound() } - const post = await getPostById(id, { + const post = (await getPostById(id, { select: { authorId: true, title: true, @@ -35,11 +39,11 @@ async function NewFromExisting({ } } } - }) + })) as ServerPostWithFiles - const serialized = JSON.stringify(post) + const clientPost = post ? serverPostToClientPost(post) : undefined - return + return } export default NewFromExisting diff --git a/src/app/(posts)/new/head.tsx b/src/app/(drift)/(posts)/new/head.tsx similarity index 100% rename from src/app/(posts)/new/head.tsx rename to src/app/(drift)/(posts)/new/head.tsx diff --git a/src/app/(drift)/(posts)/new/layout.tsx b/src/app/(drift)/(posts)/new/layout.tsx new file mode 100644 index 00000000..6be613b1 --- /dev/null +++ b/src/app/(drift)/(posts)/new/layout.tsx @@ -0,0 +1,3 @@ +export default function NewLayout({ children }: { children: React.ReactNode }) { + return <>{children} +} diff --git a/src/app/(posts)/new/page.tsx b/src/app/(drift)/(posts)/new/page.tsx similarity index 65% rename from src/app/(posts)/new/page.tsx rename to src/app/(drift)/(posts)/new/page.tsx index 93d2b9d8..85587941 100644 --- a/src/app/(posts)/new/page.tsx +++ b/src/app/(drift)/(posts)/new/page.tsx @@ -1,4 +1,4 @@ -import NewPost from "src/app/(posts)/new/components/new" +import NewPost from "src/app/(drift)/(posts)/new/components/new" import "./react-datepicker.css" export default function New() { diff --git a/src/app/(posts)/new/react-datepicker.css b/src/app/(drift)/(posts)/new/react-datepicker.css similarity index 100% rename from src/app/(posts)/new/react-datepicker.css rename to src/app/(drift)/(posts)/new/react-datepicker.css diff --git a/src/app/(posts)/post/[id]/components/header/post-buttons/index.tsx b/src/app/(drift)/(posts)/post/[id]/components/header/post-buttons/index.tsx similarity index 86% rename from src/app/(posts)/post/[id]/components/header/post-buttons/index.tsx rename to src/app/(drift)/(posts)/post/[id]/components/header/post-buttons/index.tsx index 54227fba..9d43d702 100644 --- a/src/app/(posts)/post/[id]/components/header/post-buttons/index.tsx +++ b/src/app/(drift)/(posts)/post/[id]/components/header/post-buttons/index.tsx @@ -2,28 +2,21 @@ import Button from "@components/button" import ButtonGroup from "@components/button-group" -import FileDropdown from "src/app/(posts)/components/file-dropdown" +import FileDropdown from "src/app/(drift)/(posts)/components/file-dropdown" import { Edit, ArrowUpCircle, Archive } from "react-feather" import styles from "./post-buttons.module.css" import { useRouter } from "next/navigation" import { PostWithFiles } from "@lib/server/prisma" export const PostButtons = ({ - title, - files, - loading, - postId, - parentId + post, + loading }: { - title: string - files?: Pick["files"] + post?: PostWithFiles loading?: boolean - postId?: string - parentId?: string - visibility?: string - authorId?: string }) => { const router = useRouter() + const { files, id: postId, parentId, title } = post || {} const downloadClick = async () => { if (!files?.length) return const downloadZip = (await import("client-zip")).downloadZip diff --git a/src/app/(posts)/post/[id]/components/header/post-buttons/post-buttons.module.css b/src/app/(drift)/(posts)/post/[id]/components/header/post-buttons/post-buttons.module.css similarity index 100% rename from src/app/(posts)/post/[id]/components/header/post-buttons/post-buttons.module.css rename to src/app/(drift)/(posts)/post/[id]/components/header/post-buttons/post-buttons.module.css diff --git a/src/app/(posts)/post/[id]/components/header/title/index.tsx b/src/app/(drift)/(posts)/post/[id]/components/header/title/index.tsx similarity index 76% rename from src/app/(posts)/post/[id]/components/header/title/index.tsx rename to src/app/(drift)/(posts)/post/[id]/components/header/title/index.tsx index f3d5d7a3..f10e29e0 100644 --- a/src/app/(posts)/post/[id]/components/header/title/index.tsx +++ b/src/app/(drift)/(posts)/post/[id]/components/header/title/index.tsx @@ -2,27 +2,19 @@ import CreatedAgoBadge from "@components/badges/created-ago-badge" import ExpirationBadge from "@components/badges/expiration-badge" import VisibilityBadge from "@components/badges/visibility-badge" import Skeleton from "@components/skeleton" +import { PostWithFilesAndAuthor } from "@lib/server/prisma" import styles from "./title.module.css" type TitleProps = { - title: string loading?: boolean - displayName?: string - visibility?: string - createdAt?: string - expiresAt?: string - authorId?: string + post?: PostWithFilesAndAuthor } -export const PostTitle = ({ - title, - displayName, - visibility, - createdAt, - expiresAt, - loading -}: // authorId -TitleProps) => { +export const PostTitle = ({ post, loading }: TitleProps) => { + const { title, author, visibility, createdAt, expiresAt } = post || {} + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore displayName should be present + const displayName = author?.displayName return (

{ - const initialPost = - typeof _initialPost === "string" - ? (JSON.parse(_initialPost) as PostWithFilesAndAuthor) - : _initialPost +const PostFiles = ({ post: initialPost }: Props) => { const [post, setPost] = useState(initialPost) const router = useRouter() @@ -63,15 +59,13 @@ const PostFiles = ({ post: _initialPost }: Props) => { gap: "var(--gap-double)" }} > - {post?.files?.map(({ id, content, title, html }) => ( + {post?.files?.map((file) => ( ))} diff --git a/src/app/(posts)/post/[id]/components/post-files/password-modal-wrapper.tsx b/src/app/(drift)/(posts)/post/[id]/components/post-files/password-modal-wrapper.tsx similarity index 87% rename from src/app/(posts)/post/[id]/components/post-files/password-modal-wrapper.tsx rename to src/app/(drift)/(posts)/post/[id]/components/post-files/password-modal-wrapper.tsx index bd6560ad..a3611416 100644 --- a/src/app/(posts)/post/[id]/components/post-files/password-modal-wrapper.tsx +++ b/src/app/(drift)/(posts)/post/[id]/components/post-files/password-modal-wrapper.tsx @@ -1,6 +1,6 @@ "use client" -import { Post, PostWithFilesAndAuthor } from "@lib/server/prisma" +import { PostWithFilesAndAuthor } from "@lib/server/prisma" import PasswordModal from "@components/password-modal" import { useRouter } from "next/navigation" import { useCallback, useEffect, useState } from "react" @@ -10,8 +10,8 @@ import { fetchWithUser } from "src/app/lib/fetch-with-user" type Props = { setPost: (post: PostWithFilesAndAuthor) => void - postId: Post["id"] - authorId: Post["authorId"] + postId: PostWithFilesAndAuthor["id"] + authorId: PostWithFilesAndAuthor["authorId"] } const PasswordModalWrapper = ({ setPost, postId, authorId }: Props) => { @@ -20,7 +20,9 @@ const PasswordModalWrapper = ({ setPost, postId, authorId }: Props) => { const { session, isLoading } = useSessionSWR() const isAuthor = isLoading ? undefined - : session?.user && session?.user?.id === authorId + : session?.user + ? session?.user?.id === authorId + : false const [isPasswordModalOpen, setIsPasswordModalOpen] = useState(false) const onSubmit = useCallback( async (password: string) => { @@ -64,14 +66,14 @@ const PasswordModalWrapper = ({ setPost, postId, authorId }: Props) => { } useEffect(() => { - if (isAuthor) { + if (isAuthor === true) { onSubmit("author") setToast({ message: "You're the author of this post, so you automatically have access to it.", type: "default" }) - } else { + } else if (isAuthor === false) { setIsPasswordModalOpen(true) } }, [isAuthor, onSubmit, setToast]) diff --git a/src/app/(posts)/post/[id]/components/post-files/view-document/document.module.css b/src/app/(drift)/(posts)/post/[id]/components/post-files/view-document/document.module.css similarity index 100% rename from src/app/(posts)/post/[id]/components/post-files/view-document/document.module.css rename to src/app/(drift)/(posts)/post/[id]/components/post-files/view-document/document.module.css diff --git a/src/app/(posts)/post/[id]/components/post-files/view-document/index.tsx b/src/app/(drift)/(posts)/post/[id]/components/post-files/view-document/index.tsx similarity index 52% rename from src/app/(posts)/post/[id]/components/post-files/view-document/index.tsx rename to src/app/(drift)/(posts)/post/[id]/components/post-files/view-document/index.tsx index 0f1d6d1e..844ca1ee 100644 --- a/src/app/(posts)/post/[id]/components/post-files/view-document/index.tsx +++ b/src/app/(drift)/(posts)/post/[id]/components/post-files/view-document/index.tsx @@ -1,21 +1,20 @@ -"use client" - import Button from "@components/button" import ButtonGroup from "@components/button-group" import Skeleton from "@components/skeleton" import Tooltip from "@components/tooltip" -import DocumentTabs from "src/app/(posts)/components/tabs" +import DocumentTabs from "src/app/(drift)/(posts)/components/tabs" import Link from "next/link" import { memo } from "react" -import { Download, ExternalLink } from "react-feather" +import { Download, ExternalLink, Globe } from "react-feather" import styles from "./document.module.css" +import { getURLFriendlyTitle } from "src/app/lib/get-url-friendly-title" +import { PostWithFiles, ServerPost } from "@lib/server/prisma" +import { isAllowedVisibilityForWebpage } from "@lib/constants" type SharedProps = { - title?: string initialTab: "edit" | "preview" - id?: string - content?: string - preview?: string + file?: PostWithFiles["files"][0] + post?: Pick } type Props = ( @@ -28,7 +27,13 @@ type Props = ( ) & SharedProps -const DownloadButtons = ({ rawLink }: { rawLink?: string }) => { +const DownloadButtons = ({ + rawLink, + siteLink +}: { + rawLink?: string + siteLink?: string +}) => { return ( @@ -44,15 +49,28 @@ const DownloadButtons = ({ rawLink }: { rawLink?: string }) => { /> - - -