From 5a634432f6925bbfb71f132f6f9d0494a24cdf40 Mon Sep 17 00:00:00 2001 From: dethan3 Date: Mon, 13 Jul 2026 16:48:00 +0800 Subject: [PATCH 1/2] [fix] repair Open Library borrowing page rendering Preserve translation resolver functions across SSR serialization and render paragraph Markdown inline to prevent runtime and hydration errors. --- models/Translation.ts | 26 +++- pages/open-library/how-to-borrow.tsx | 12 +- pnpm-lock.yaml | 176 +++++++++++++-------------- 3 files changed, 114 insertions(+), 100 deletions(-) diff --git a/models/Translation.ts b/models/Translation.ts index 83a7018..dfcec4e 100644 --- a/models/Translation.ts +++ b/models/Translation.ts @@ -1,4 +1,10 @@ -import { loadLanguageMapFrom, TranslationMap, TranslationModel } from 'mobx-i18n'; +import { + decodeFunctions, + encodeFunctions, + loadLanguageMapFrom, + TranslationMap, + TranslationModel, +} from 'mobx-i18n'; import { DataObject } from 'mobx-restful'; import { NextPageContext } from 'next'; import { createContext } from 'react'; @@ -15,15 +21,18 @@ export type LanguageCode = keyof typeof i18nData; export interface I18nProps { language: LanguageCode; - languageMap: typeof zhCN; + languageMap: string; } export type I18nKey = keyof typeof zhCN; export const createI18nStore = ( language?: N, - data?: TranslationMap, + serializedData?: string, ) => { + const data = serializedData + ? (JSON.parse(serializedData, decodeFunctions) as TranslationMap) + : undefined; const store = new TranslationModel({ ...i18nData, ...(language && { [language]: data }), @@ -57,7 +66,7 @@ export const parseSSRContext = ( return cookie; }; -export const loadSSRLanguage = (context: NextPageContext) => { +export const loadSSRLanguage = async (context: NextPageContext) => { const { headers } = context.req || {}, { language } = parseSSRContext(context, ['language']); const header = { @@ -65,5 +74,12 @@ export const loadSSRLanguage = (context: NextPageContext) => { ...(language ? { cookie: `language=${language}` } : {}), }; - return loadLanguageMapFrom(i18nData, header); + const result = await loadLanguageMapFrom(i18nData, header); + + if (!result) return result; + + return { + ...result, + languageMap: JSON.stringify(result.languageMap, encodeFunctions), + }; }; diff --git a/pages/open-library/how-to-borrow.tsx b/pages/open-library/how-to-borrow.tsx index c524271..2cceaba 100644 --- a/pages/open-library/how-to-borrow.tsx +++ b/pages/open-library/how-to-borrow.tsx @@ -70,11 +70,15 @@ const HowToBorrowPage = observer(() => {

{t('borrowing_and_passing')}

@@ -95,7 +99,9 @@ const HowToBorrowPage = observer(() => {

{title}

diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9c47178..319feee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ overrides: patchedDependencies: next@16.2.10: - hash: 3ruvu6fsawejy2nd3hex2n2nbe + hash: 2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc path: patches/next@16.2.10.patch importers: @@ -94,13 +94,13 @@ importers: version: 0.8.1(core-js@3.49.0)(typescript@5.9.3) next: specifier: 16.2.10 - version: 16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0) + version: 16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0) next-pwa: specifier: ^5.6.0 - version: 5.6.0(@babel/core@7.29.7)(next@16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0))(postcss@8.4.31) + version: 5.6.0(@babel/core@7.29.7)(next@16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0))(postcss@8.4.31) next-ssr-middleware: specifier: ^1.1.0 - version: 1.1.0(next@16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0))(react@19.2.7)(typescript@5.9.3) + version: 1.1.0(next@16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0))(react@19.2.7)(typescript@5.9.3) nodemailer: specifier: ^9.0.3 version: 9.0.3 @@ -206,7 +206,7 @@ importers: version: 17.0.8 next-with-less: specifier: ^3.0.1 - version: 3.0.1(less-loader@13.0.0(less@4.6.7))(less@4.6.7)(next@16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0)) + version: 3.0.1(less-loader@13.0.0(less@4.6.7))(less@4.6.7)(next@16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0)) prettier: specifier: ^3.9.5 version: 3.9.5 @@ -777,8 +777,8 @@ packages: '@cspell/dict-bash@4.2.3': resolution: {integrity: sha512-ljUZoKHbDqw5Sx0qpL2qTUlmkmr+vhZH/sCNrNaBZKTbdgiswErSnIF1jRbGmEitJNxHRHWsuZyVgnTGfVO1Yw==} - '@cspell/dict-companies@3.2.11': - resolution: {integrity: sha512-0cmafbcz2pTHXLd59eLR1gvDvN6aWAOM0+cIL4LLF9GX9yB2iKDNrKsvs4tJRqutoaTdwNFBbV0FYv+6iCtebQ==} + '@cspell/dict-companies@3.2.12': + resolution: {integrity: sha512-mjiz/N3zWOCsz5VfwMUydSl7uW0OU9H2PnbCNc3RV44Vj6Q59CSp6EYGSGZQxrXU1gpsuZUrwr6QCjNjFOOg5A==} '@cspell/dict-cpp@7.0.2': resolution: {integrity: sha512-dfbeERiVNeqmo/npivdR6rDiBCqZi3QtjH2Z0HFcXwpdj6i97dX1xaKyK2GUsO/p4u1TOv63Dmj5Vm48haDpuA==} @@ -795,8 +795,8 @@ packages: '@cspell/dict-dart@2.3.2': resolution: {integrity: sha512-sUiLW56t9gfZcu8iR/5EUg+KYyRD83Cjl3yjDEA2ApVuJvK1HhX+vn4e4k4YfjpUQMag8XO2AaRhARE09+/rqw==} - '@cspell/dict-data-science@2.0.14': - resolution: {integrity: sha512-jl6Ds4u5u5JT+yY30pWQpAbdCHfy3lCcNkLbpL/AZKoUaLEoXbaYsps9xQtvD7DyaiXxiLZkdH2yHHXtoFtZyg==} + '@cspell/dict-data-science@2.0.16': + resolution: {integrity: sha512-M72mxv5asuAnORurz4iXRJ+Tw9XBq6eu7D2Ne7biP0Z1RciKGNxXWu9JycA/KlVvK1hAlKj/fANlXhuEWpXKFg==} '@cspell/dict-django@4.1.6': resolution: {integrity: sha512-SdbSFDGy9ulETqNz15oWv2+kpWLlk8DJYd573xhIkeRdcXOjskRuxjSZPKfW7O3NxN/KEf3gm3IevVOiNuFS+w==} @@ -810,14 +810,14 @@ packages: '@cspell/dict-elixir@4.0.8': resolution: {integrity: sha512-CyfphrbMyl4Ms55Vzuj+mNmd693HjBFr9hvU+B2YbFEZprE5AG+EXLYTMRWrXbpds4AuZcvN3deM2XVB80BN/Q==} - '@cspell/dict-en-common-misspellings@2.1.12': - resolution: {integrity: sha512-14Eu6QGqyksqOd4fYPuRb58lK1Va7FQK9XxFsRKnZU8LhL3N+kj7YKDW+7aIaAN/0WGEqslGP6lGbQzNti8Akw==} + '@cspell/dict-en-common-misspellings@2.1.13': + resolution: {integrity: sha512-00rpydUxKNWY2xxrSx+h46aNWLvbkJdd57SsnEFt24fbs1fROhXZ6XSQu+gQz/zNuiCvFi4Ro3ej9DLbEdWQmQ==} - '@cspell/dict-en-gb-mit@3.1.24': - resolution: {integrity: sha512-Oowb/Uzkh7OmDRdCcETzMc9imEb4IpLlHJXoYjX8A8DS2X/54gqSjI915JFB8hKtFjBko5OM0BLQ+6cZhFEMmQ==} + '@cspell/dict-en-gb-mit@3.1.25': + resolution: {integrity: sha512-zGODptk24CMrXi49ieG2SUm94CKxEsVF0dYNF+1ZYH0MSsQDZ/PKDlrrbvtBqSupKdPSj0Z9sjOmMNfHHW9ZSg==} - '@cspell/dict-en_us@4.4.35': - resolution: {integrity: sha512-xWpxBCc/FzzMMo/A+0qwARVaIIhR0Ql8yhhv4rvsvg+GfQF+LG9yzg2GwTM5N2rjvzmM3nKuR9zxFZq2I6fJSg==} + '@cspell/dict-en_us@4.4.36': + resolution: {integrity: sha512-2yOhI/+7d1DbfvMljGW4jw8pLqDEsVmnvUXBOCFXtLU2BWgQkrqOJDCNseYjEiEbTp0OtdrWEWWPFSP1TNugQw==} '@cspell/dict-filetypes@3.0.18': resolution: {integrity: sha512-yU7RKD/x1IWmDLzWeiItMwgV+6bUcU/af23uS0+uGiFUbsY1qWV/D4rxlAAO6Z7no3J2z8aZOkYIOvUrJq0Rcw==} @@ -861,8 +861,8 @@ packages: '@cspell/dict-julia@1.1.1': resolution: {integrity: sha512-WylJR9TQ2cgwd5BWEOfdO3zvDB+L7kYFm0I9u0s9jKHWQ6yKmfKeMjU9oXxTBxIufhCXm92SKwwVNAC7gjv+yA==} - '@cspell/dict-k8s@1.0.12': - resolution: {integrity: sha512-2LcllTWgaTfYC7DmkMPOn9GsBWsA4DZdlun4po8s2ysTP7CPEnZc1ZfK6pZ2eI4TsZemlUQQ+NZxMe9/QutQxg==} + '@cspell/dict-k8s@1.0.13': + resolution: {integrity: sha512-ELGkS13k7K/NEfVimBSrxVTfqXvOF/Kvxj4I62YxRm8bvHbfoXgrGaOx28lPiNRz+dmu+yYtvuXbnURKtYbC6g==} '@cspell/dict-kotlin@1.1.1': resolution: {integrity: sha512-J3NzzfgmxRvEeOe3qUXnSJQCd38i/dpF9/t3quuWh6gXM+krsAXP75dY1CzDmS8mrJAlBdVBeAW5eAZTD8g86Q==} @@ -893,8 +893,8 @@ packages: '@cspell/dict-node@5.0.9': resolution: {integrity: sha512-hO+ga+uYZ/WA4OtiMEyKt5rDUlUyu3nXMf8KVEeqq2msYvAPdldKBGH7lGONg6R/rPhv53Rb+0Y1SLdoK1+7wQ==} - '@cspell/dict-npm@5.2.41': - resolution: {integrity: sha512-To3xsfRmMBYVXtWVEdUgV35M9a/JZ54dSuoY6m6D3uHKKL3I326Wmy4xifZ3PU8MQaWhyEH7zbIcUEtKwTQMcA==} + '@cspell/dict-npm@5.2.43': + resolution: {integrity: sha512-H2gYwtu59dNO9662Uq0usfuhyNd7lZJE1C61a/UXcpRyWWSrTo2Bz+vwGYp1bXZ1LmjXadqvwJ8ArFlGdiadNQ==} '@cspell/dict-php@4.1.1': resolution: {integrity: sha512-EXelI+4AftmdIGtA8HL8kr4WlUE11OqCSVlnIgZekmTkEGSZdYnkFdiJ5IANSALtlQ1mghKjz+OFqVs6yowgWA==} @@ -905,8 +905,8 @@ packages: '@cspell/dict-public-licenses@2.0.16': resolution: {integrity: sha512-EQRrPvEOmwhwWezV+W7LjXbIBjiy6y/shrET6Qcpnk3XANTzfvWflf9PnJ5kId/oKWvihFy0za0AV1JHd03pSQ==} - '@cspell/dict-python@4.2.27': - resolution: {integrity: sha512-Rj6xQgYS4X6ienjgAZF+njA0GRY4oSPouJWv0vfikCTn6EWlfk0V6Dy1HP3Migj1O+IC2NmespgVq+BZNSp8OA==} + '@cspell/dict-python@4.2.29': + resolution: {integrity: sha512-OnEt1a35iuQzc2Ize1qU/43ZyF10urRKAm+mlTz++vnAgDLBHpKfWakpSK50nyL5/1WvyQ8BaMjb52MBLEpTeA==} '@cspell/dict-r@2.1.1': resolution: {integrity: sha512-71Ka+yKfG4ZHEMEmDxc6+blFkeTTvgKbKAbwiwQAuKl3zpqs1Y0vUtwW2N4b3LgmSPhV3ODVY0y4m5ofqDuKMw==} @@ -923,8 +923,8 @@ packages: '@cspell/dict-shell@1.2.0': resolution: {integrity: sha512-PVctvT22lJ49niMiakO8xieY7ELCAzjSqhejWR7bAMb5AZ9F4WDEs+XdGMnoVHWeXq7K5rcepLPmEJb+37zzIw==} - '@cspell/dict-software-terms@5.2.2': - resolution: {integrity: sha512-0CaYd6TAsKtEoA7tNswm1iptEblTzEe3UG8beG2cpSTHk7afWIVMtJLgXDv0f/Li67Lf3Z1Jf3JeXR7GsJ2TRw==} + '@cspell/dict-software-terms@5.2.4': + resolution: {integrity: sha512-z6y/TGH3QNf5wB4pVvN/P3GfFEW/Whf6QAekNsIn06VKl95dnamfpkPWqV8rEtCixQFaKalb5+y9hRQXH3XQ1g==} '@cspell/dict-sql@2.2.1': resolution: {integrity: sha512-qDHF8MpAYCf4pWU8NKbnVGzkoxMNrFqBHyG/dgrlic5EQiKANCLELYtGlX5auIMDLmTf1inA0eNtv74tyRJ/vg==} @@ -935,8 +935,8 @@ packages: '@cspell/dict-swift@2.0.6': resolution: {integrity: sha512-PnpNbrIbex2aqU1kMgwEKvCzgbkHtj3dlFLPMqW1vSniop7YxaDTtvTUO4zA++ugYAEL+UK8vYrBwDPTjjvSnA==} - '@cspell/dict-terraform@1.1.3': - resolution: {integrity: sha512-gr6wxCydwSFyyBKhBA2xkENXtVFToheqYYGFvlMZXWjviynXmh+NK/JTvTCk/VHk3+lzbO9EEQKee6VjrAUSbA==} + '@cspell/dict-terraform@1.1.4': + resolution: {integrity: sha512-Ere42ilvMFvQA4GlcN0OKlruMPR6EsvaB+iTHzj2xc+NJGRK64V7yApUcWrOrSgTiM/vhWXPIsK3OMfiAiNdmA==} '@cspell/dict-typescript@3.2.3': resolution: {integrity: sha512-zXh1wYsNljQZfWWdSPYwQhpwiuW0KPW1dSd8idjMRvSD0aSvWWHoWlrMsmZeRl4qM4QCEAjua8+cjflm41cQBg==} @@ -2086,11 +2086,11 @@ packages: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} - browser-fs-access@0.37.0: - resolution: {integrity: sha512-MKpvZrKtv6pBJ2ACd+VwfS9XauBKTMVZg2UBibypuK1gfiXM7euZjbdKmvRsyxeQRhfzNVQrzCSVGXs19/LP8Q==} + browser-fs-access@0.38.0: + resolution: {integrity: sha512-JveqW2w6pEZqFEEfMgCszXzYpE89dG+nPsmOdcs741mFFAROeL+iqjGEpR07RI+s0YY0EFr+4KnOoACprJTpOw==} - browserslist@4.28.5: - resolution: {integrity: sha512-Cu2E6QejHWzuDMTkuwgpABFgDfZrXLQq5V13YOACZx4mFAG4IwGTbTfHPMr4WtxlHoXSM8FIuRwYYCz5XiabaQ==} + browserslist@4.28.6: + resolution: {integrity: sha512-FQBYNK15VMslhLHpA7+n+n1GOlF1kId2xcCg7/j95f24AOF6VDYMNH4mFxF7KuaTdv627faazpOAjFzMrfJOUw==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true @@ -2120,8 +2120,8 @@ packages: resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==} engines: {node: '>= 0.4'} - caniuse-lite@1.0.30001803: - resolution: {integrity: sha512-g/uHREV2ZpK9qMalCsWaxmA6ol+DX8GYhuf3T40RKoP+oL7vhRJh8LNt73PCjpnR6l14FzfPrB5Yux4PKm2meg==} + caniuse-lite@1.0.30001805: + resolution: {integrity: sha512-52noaS3DubycKSXaU30TwPGIp+POyQSUVa5jBEq3vkRkY0kjyb3LQgvhU6WGyCcyXqVLWO0Cw0Q6BSdD0kUfVA==} ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} @@ -2403,8 +2403,8 @@ packages: editorjs-html@4.0.5: resolution: {integrity: sha512-ImQYxB3fNCJcd+nJ+Vbne/6PxidO1cYByNpu9nBDStVabfjVrMW65BuR+IEZfOii8VKYH+CW/lYDb2GDlzZtDg==} - edkit@1.2.7: - resolution: {integrity: sha512-dCOBN9MMbCaCdSqhnZTSHPe7lu53TQttttjVBxLE/TehsQasuxmqW3ckimVODFaJVci1A6w429j9bebpiU3zKg==} + edkit@1.3.0: + resolution: {integrity: sha512-Fn6N4V7KDJAz0ZnH0ajrjMmRaD01nMPLlmmPtiIj52o0C4DEo8V1Wf/2ibWvggzpcJK1mA+WJLBVNduVYVPrkw==} ee-first@1.1.1: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} @@ -3259,7 +3259,6 @@ packages: keygrip@1.1.0: resolution: {integrity: sha512-iYSchDJ+liQ8iwbSI2QqsQOvqv58eJCEanyJPJi+Khyu8smkcKSFUCbPwzFcL7YVtZ6eONjqRX/38caJ7QjRAQ==} engines: {node: '>= 0.6'} - deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} @@ -3428,11 +3427,6 @@ packages: resolution: {integrity: sha512-o5vL7aDWatOTX8LzaS1WMoaoxIiLRQJuIKKe2wAw6IeULDHaqbiqiggmx+pKvZDb1Sj+pE46Sn1T7lCqfFtg1Q==} engines: {node: '>=16'} - marked@15.0.12: - resolution: {integrity: sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA==} - engines: {node: '>= 18'} - hasBin: true - marked@18.0.6: resolution: {integrity: sha512-MrV5puXBfuiy6wl6DLaq3BtIJQAJToAd5zt/ZKhRfGRAuFPALE7/4Y7jnxRQoEgK/pBgurGqLyAuRgZ2xOjr6w==} engines: {node: '>= 20'} @@ -3689,8 +3683,8 @@ packages: mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} - nanoid@3.3.15: - resolution: {integrity: sha512-y7Wygv/7mEOvxTuEQDB8StXdMRBWf1kR/tlhAzBRUFkB2jfcLOAxO/SHmOO2zgz1pVgK29/kyupn059/bCHdjA==} + nanoid@3.3.16: + resolution: {integrity: sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true @@ -4017,8 +4011,8 @@ packages: react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1 react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1 - react-bootstrap-editor@2.1.1: - resolution: {integrity: sha512-vnAy1MSn4mAZp418cz3R7IiUWXGGwNfmWQYlPUa2MWGm6hTTxJVeKTp2jhrH3n8sbbtg2MN4/co44OP+sZn1pQ==} + react-bootstrap-editor@2.1.2: + resolution: {integrity: sha512-MLP4ocZujco4AAlkyLFL9qV4q1qBlzc7NY6BRHS1uXqC2eZcXCNPbewj/NCEAUIALuFdIsVid+aRbRaS5xIOIA==} peerDependencies: react: '>=16' react-dom: '>=16' @@ -4959,7 +4953,7 @@ snapshots: dependencies: '@babel/compat-data': 7.29.7 '@babel/helper-validator-option': 7.29.7 - browserslist: 4.28.5 + browserslist: 4.28.6 lru-cache: 5.1.1 semver: 6.3.1 @@ -5590,20 +5584,20 @@ snapshots: '@cspell/dict-al': 1.1.1 '@cspell/dict-aws': 4.0.17 '@cspell/dict-bash': 4.2.3 - '@cspell/dict-companies': 3.2.11 + '@cspell/dict-companies': 3.2.12 '@cspell/dict-cpp': 7.0.2 '@cspell/dict-cryptocurrencies': 5.0.5 '@cspell/dict-csharp': 4.0.8 '@cspell/dict-css': 4.1.2 '@cspell/dict-dart': 2.3.2 - '@cspell/dict-data-science': 2.0.14 + '@cspell/dict-data-science': 2.0.16 '@cspell/dict-django': 4.1.6 '@cspell/dict-docker': 1.1.17 '@cspell/dict-dotnet': 5.0.13 '@cspell/dict-elixir': 4.0.8 - '@cspell/dict-en-common-misspellings': 2.1.12 - '@cspell/dict-en-gb-mit': 3.1.24 - '@cspell/dict-en_us': 4.4.35 + '@cspell/dict-en-common-misspellings': 2.1.13 + '@cspell/dict-en-gb-mit': 3.1.25 + '@cspell/dict-en_us': 4.4.36 '@cspell/dict-filetypes': 3.0.18 '@cspell/dict-flutter': 1.1.1 '@cspell/dict-fonts': 4.0.6 @@ -5618,7 +5612,7 @@ snapshots: '@cspell/dict-html-symbol-entities': 4.0.5 '@cspell/dict-java': 5.0.12 '@cspell/dict-julia': 1.1.1 - '@cspell/dict-k8s': 1.0.12 + '@cspell/dict-k8s': 1.0.13 '@cspell/dict-kotlin': 1.1.1 '@cspell/dict-latex': 5.1.0 '@cspell/dict-lorem-ipsum': 4.0.5 @@ -5627,21 +5621,21 @@ snapshots: '@cspell/dict-markdown': 2.0.17(@cspell/dict-css@4.1.2)(@cspell/dict-html-symbol-entities@4.0.5)(@cspell/dict-html@4.0.15)(@cspell/dict-typescript@3.2.3) '@cspell/dict-monkeyc': 1.0.12 '@cspell/dict-node': 5.0.9 - '@cspell/dict-npm': 5.2.41 + '@cspell/dict-npm': 5.2.43 '@cspell/dict-php': 4.1.1 '@cspell/dict-powershell': 5.0.15 '@cspell/dict-public-licenses': 2.0.16 - '@cspell/dict-python': 4.2.27 + '@cspell/dict-python': 4.2.29 '@cspell/dict-r': 2.1.1 '@cspell/dict-ruby': 5.1.1 '@cspell/dict-rust': 4.1.2 '@cspell/dict-scala': 5.0.9 '@cspell/dict-shell': 1.2.0 - '@cspell/dict-software-terms': 5.2.2 + '@cspell/dict-software-terms': 5.2.4 '@cspell/dict-sql': 2.2.1 '@cspell/dict-svelte': 1.0.7 '@cspell/dict-swift': 2.0.6 - '@cspell/dict-terraform': 1.1.3 + '@cspell/dict-terraform': 1.1.4 '@cspell/dict-typescript': 3.2.3 '@cspell/dict-vue': 3.0.5 '@cspell/dict-zig': 1.0.0 @@ -5668,7 +5662,7 @@ snapshots: dependencies: '@cspell/dict-shell': 1.2.0 - '@cspell/dict-companies@3.2.11': {} + '@cspell/dict-companies@3.2.12': {} '@cspell/dict-cpp@7.0.2': {} @@ -5680,7 +5674,7 @@ snapshots: '@cspell/dict-dart@2.3.2': {} - '@cspell/dict-data-science@2.0.14': {} + '@cspell/dict-data-science@2.0.16': {} '@cspell/dict-django@4.1.6': {} @@ -5690,11 +5684,11 @@ snapshots: '@cspell/dict-elixir@4.0.8': {} - '@cspell/dict-en-common-misspellings@2.1.12': {} + '@cspell/dict-en-common-misspellings@2.1.13': {} - '@cspell/dict-en-gb-mit@3.1.24': {} + '@cspell/dict-en-gb-mit@3.1.25': {} - '@cspell/dict-en_us@4.4.35': {} + '@cspell/dict-en_us@4.4.36': {} '@cspell/dict-filetypes@3.0.18': {} @@ -5724,7 +5718,7 @@ snapshots: '@cspell/dict-julia@1.1.1': {} - '@cspell/dict-k8s@1.0.12': {} + '@cspell/dict-k8s@1.0.13': {} '@cspell/dict-kotlin@1.1.1': {} @@ -5747,7 +5741,7 @@ snapshots: '@cspell/dict-node@5.0.9': {} - '@cspell/dict-npm@5.2.41': {} + '@cspell/dict-npm@5.2.43': {} '@cspell/dict-php@4.1.1': {} @@ -5755,9 +5749,9 @@ snapshots: '@cspell/dict-public-licenses@2.0.16': {} - '@cspell/dict-python@4.2.27': + '@cspell/dict-python@4.2.29': dependencies: - '@cspell/dict-data-science': 2.0.14 + '@cspell/dict-data-science': 2.0.16 '@cspell/dict-r@2.1.1': {} @@ -5769,7 +5763,7 @@ snapshots: '@cspell/dict-shell@1.2.0': {} - '@cspell/dict-software-terms@5.2.2': {} + '@cspell/dict-software-terms@5.2.4': {} '@cspell/dict-sql@2.2.1': {} @@ -5777,7 +5771,7 @@ snapshots: '@cspell/dict-swift@2.0.6': {} - '@cspell/dict-terraform@1.1.3': {} + '@cspell/dict-terraform@1.1.4': {} '@cspell/dict-typescript@3.2.3': {} @@ -6491,7 +6485,7 @@ snapshots: '@types/node': 24.13.3 '@types/react': 19.2.17 '@types/react-dom': 19.2.3(@types/react@19.2.17) - next: 16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0) + next: 16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0) workbox-build: 6.6.0 transitivePeerDependencies: - '@babel/core' @@ -6934,15 +6928,15 @@ snapshots: dependencies: fill-range: 7.1.1 - browser-fs-access@0.37.0: {} + browser-fs-access@0.38.0: {} - browserslist@4.28.5: + browserslist@4.28.6: dependencies: baseline-browser-mapping: 2.10.43 - caniuse-lite: 1.0.30001803 + caniuse-lite: 1.0.30001805 electron-to-chromium: 1.5.389 node-releases: 2.0.51 - update-browserslist-db: 1.2.3(browserslist@4.28.5) + update-browserslist-db: 1.2.3(browserslist@4.28.6) buffer-equal-constant-time@1.0.1: {} @@ -6969,7 +6963,7 @@ snapshots: call-bind-apply-helpers: 1.0.2 get-intrinsic: 1.3.0 - caniuse-lite@1.0.30001803: {} + caniuse-lite@1.0.30001805: {} ccount@2.0.1: {} @@ -7062,7 +7056,7 @@ snapshots: core-js-compat@3.49.0: dependencies: - browserslist: 4.28.5 + browserslist: 4.28.6 core-js@3.49.0: {} @@ -7261,12 +7255,12 @@ snapshots: editorjs-html@4.0.5: {} - edkit@1.2.7(typescript@5.9.3): + edkit@1.3.0(typescript@5.9.3): dependencies: '@swc/helpers': 0.5.23 '@types/turndown': 5.0.6 - browser-fs-access: 0.37.0 - marked: 15.0.12 + browser-fs-access: 0.38.0 + marked: 18.0.6 regenerator-runtime: 0.14.1 turndown: 7.2.4 turndown-plugin-gfm: 1.0.2 @@ -8542,8 +8536,6 @@ snapshots: markdown-extensions@2.0.0: {} - marked@15.0.12: {} - marked@18.0.6: {} math-intrinsics@1.1.0: {} @@ -9000,7 +8992,7 @@ snapshots: mobx-restful: 2.1.4(core-js@3.49.0)(mobx@6.16.1)(typescript@5.9.3) react: 19.2.7 react-bootstrap: 2.10.10(@types/react@19.2.17)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) - react-bootstrap-editor: 2.1.1(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(typescript@5.9.3) + react-bootstrap-editor: 2.1.2(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(typescript@5.9.3) regenerator-runtime: 0.14.1 web-utility: 4.7.2(typescript@5.9.3) transitivePeerDependencies: @@ -9052,7 +9044,7 @@ snapshots: object-assign: 4.1.1 thenify-all: 1.6.0 - nanoid@3.3.15: {} + nanoid@3.3.16: {} napi-postinstall@0.3.4: {} @@ -9066,12 +9058,12 @@ snapshots: negotiator@0.6.3: {} - next-pwa@5.6.0(@babel/core@7.29.7)(next@16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0))(postcss@8.4.31): + next-pwa@5.6.0(@babel/core@7.29.7)(next@16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0))(postcss@8.4.31): dependencies: babel-loader: 8.4.1(@babel/core@7.29.7) clean-webpack-plugin: 4.0.0 globby: 11.1.0 - next: 16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0) + next: 16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0) terser-webpack-plugin: 5.6.1(postcss@8.4.31) workbox-webpack-plugin: 6.6.0 workbox-window: 6.6.0 @@ -9093,7 +9085,7 @@ snapshots: - uglify-js - webpack - next-ssr-middleware@1.1.0(next@16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0))(react@19.2.7)(typescript@5.9.3): + next-ssr-middleware@1.1.0(next@16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0))(react@19.2.7)(typescript@5.9.3): dependencies: '@koa/bodyparser': 6.1.0(koa@3.2.1) '@koa/router': 15.7.0(koa@3.2.1) @@ -9102,7 +9094,7 @@ snapshots: '@types/react': 19.2.17 jsonwebtoken: 9.0.3 koa: 3.2.1 - next: 16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0) + next: 16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0) react: 19.2.7 tslib: 2.8.1 web-utility: 4.7.2(typescript@5.9.3) @@ -9111,19 +9103,19 @@ snapshots: - supports-color - typescript - next-with-less@3.0.1(less-loader@13.0.0(less@4.6.7))(less@4.6.7)(next@16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0)): + next-with-less@3.0.1(less-loader@13.0.0(less@4.6.7))(less@4.6.7)(next@16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0)): dependencies: clone-deep: 4.0.1 less: 4.6.7 less-loader: 13.0.0(less@4.6.7) - next: 16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0) + next: 16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0) - next@16.2.10(patch_hash=3ruvu6fsawejy2nd3hex2n2nbe)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0): + next@16.2.10(patch_hash=2656f13eae5e46358e749a46a5d0d1a8e007c34856c8b9c28076813a569204cc)(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(sass@1.101.0): dependencies: '@next/env': 16.2.10 '@swc/helpers': 0.5.15 baseline-browser-mapping: 2.10.43 - caniuse-lite: 1.0.30001803 + caniuse-lite: 1.0.30001805 postcss: 8.4.31 react: 19.2.7 react-dom: 19.2.7(react@19.2.7) @@ -9340,7 +9332,7 @@ snapshots: postcss@8.4.31: dependencies: - nanoid: 3.3.15 + nanoid: 3.3.16 picocolors: 1.1.1 source-map-js: 1.2.1 @@ -9418,10 +9410,10 @@ snapshots: react-stately: 3.48.0(react@19.2.7) use-sync-external-store: 1.6.0(react@19.2.7) - react-bootstrap-editor@2.1.1(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(typescript@5.9.3): + react-bootstrap-editor@2.1.2(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(typescript@5.9.3): dependencies: '@swc/helpers': 0.5.23 - edkit: 1.2.7(typescript@5.9.3) + edkit: 1.3.0(typescript@5.9.3) mobx: 6.16.1 mobx-react: 9.2.2(mobx@6.16.1)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) mobx-react-helper: 0.5.1(mobx@6.16.1)(react@19.2.7)(typescript@5.9.3) @@ -10299,9 +10291,9 @@ snapshots: upath@1.2.0: {} - update-browserslist-db@1.2.3(browserslist@4.28.5): + update-browserslist-db@1.2.3(browserslist@4.28.6): dependencies: - browserslist: 4.28.5 + browserslist: 4.28.6 escalade: 3.2.0 picocolors: 1.1.1 From 407ab24249c3a70ea01071373b85385393e0b865 Mon Sep 17 00:00:00 2001 From: South Drifter Date: Wed, 15 Jul 2026 02:58:03 +0000 Subject: [PATCH 2/2] [optimize] simplify PR Author codes --- models/Translation.ts | 17 +++++++---------- pages/open-library/book/[id].tsx | 13 ++++++++++--- pages/open-library/how-to-borrow.tsx | 12 +++--------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/models/Translation.ts b/models/Translation.ts index dfcec4e..15afde9 100644 --- a/models/Translation.ts +++ b/models/Translation.ts @@ -30,9 +30,8 @@ export const createI18nStore = ( language?: N, serializedData?: string, ) => { - const data = serializedData - ? (JSON.parse(serializedData, decodeFunctions) as TranslationMap) - : undefined; + const data = serializedData && (JSON.parse(serializedData, decodeFunctions) as TranslationMap); + const store = new TranslationModel({ ...i18nData, ...(language && { [language]: data }), @@ -73,13 +72,11 @@ export const loadSSRLanguage = async (context: NextPageContext) => { ...headers, ...(language ? { cookie: `language=${language}` } : {}), }; - const result = await loadLanguageMapFrom(i18nData, header); - if (!result) return result; - - return { - ...result, - languageMap: JSON.stringify(result.languageMap, encodeFunctions), - }; + if (result) + return { + ...result, + languageMap: JSON.stringify(result.languageMap, encodeFunctions), + }; }; diff --git a/pages/open-library/book/[id].tsx b/pages/open-library/book/[id].tsx index ea0f2ad..a39e498 100644 --- a/pages/open-library/book/[id].tsx +++ b/pages/open-library/book/[id].tsx @@ -7,14 +7,21 @@ import { Badge, Button, Card, Col, Container, Row, Tab, Table, Tabs } from 'reac import { formatDate } from 'web-utility'; import { PageHead } from '../../../components/Layout/PageHead'; +import { larkClient } from '../../../models/Base'; import type { Book, BookReview, BorrowHistory } from '../../../models/Book'; -import { OpenLibraryBorrowFormURL, OpenLibraryReviewFormURL } from '../../../models/configuration'; +import { + API_Host, + OpenLibraryBorrowFormURL, + OpenLibraryReviewFormURL, +} from '../../../models/configuration'; import { I18nContext } from '../../../models/Translation'; -import { openLibraryBooks } from '../../api/open-library/books'; export const getServerSideProps: GetServerSideProps = async ({ params }) => { const bookId = +(params!.id + ''); - const book = openLibraryBooks.find(({ id }) => id === bookId); + + const { body } = await larkClient.get(`${API_Host}/api/open-library/books`); + + const book = body!.find(({ id }) => id === bookId); return book ? { props: book } : { notFound: true }; }; diff --git a/pages/open-library/how-to-borrow.tsx b/pages/open-library/how-to-borrow.tsx index 2cceaba..c524271 100644 --- a/pages/open-library/how-to-borrow.tsx +++ b/pages/open-library/how-to-borrow.tsx @@ -70,15 +70,11 @@ const HowToBorrowPage = observer(() => {

{t('borrowing_and_passing')}

@@ -99,9 +95,7 @@ const HowToBorrowPage = observer(() => {

{title}