From 6758b4450860622828a63f76dcf2d031e2219f94 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Tue, 21 Feb 2023 18:58:34 +0900 Subject: [PATCH] [WMAS-46] remove temporal patch code for file downloading See https://github.com/gatsbyjs/gatsby/issues/35636 Resolves [WMAS-46] --- .../gatsby/gatsby-config.ts | 8 +++- .../gatsby-theme-website-team/package.json | 1 - team.daangn.com/gatsby-node.ts | 45 ------------------- team.daangn.com/src/templates/IrPage.tsx | 26 ++++------- 4 files changed, 15 insertions(+), 65 deletions(-) diff --git a/_packages/@karrotmarket/gatsby-theme-website-team/gatsby/gatsby-config.ts b/_packages/@karrotmarket/gatsby-theme-website-team/gatsby/gatsby-config.ts index edc9d9716..fdeff492a 100644 --- a/_packages/@karrotmarket/gatsby-theme-website-team/gatsby/gatsby-config.ts +++ b/_packages/@karrotmarket/gatsby-theme-website-team/gatsby/gatsby-config.ts @@ -20,7 +20,13 @@ const config = ({ 'gatsby-theme-stitches', 'gatsby-plugin-svgr', 'gatsby-plugin-head-seo', - 'gatsby-transformer-remote-filesystem', + { + resolve: 'gatsby-source-filesystem', + options: { + name: 'placeholder', + path: `${__dirname}/package.json`, + }, + }, { resolve: 'gatsby-plugin-turnstile', options: { diff --git a/_packages/@karrotmarket/gatsby-theme-website-team/package.json b/_packages/@karrotmarket/gatsby-theme-website-team/package.json index 4e9c45c97..78ee5c17c 100644 --- a/_packages/@karrotmarket/gatsby-theme-website-team/package.json +++ b/_packages/@karrotmarket/gatsby-theme-website-team/package.json @@ -51,7 +51,6 @@ "gatsby-source-filesystem": "5.6.0", "gatsby-source-prismic": "6.0.0-alpha.19", "gatsby-theme-stitches": "1.0.1", - "gatsby-transformer-remote-filesystem": "1.0.0", "gatsby-transformer-sharp": "5.6.0", "hangul-js": "0.2.6", "polished": "4.2.2", diff --git a/team.daangn.com/gatsby-node.ts b/team.daangn.com/gatsby-node.ts index 6656f2b6d..093f73d79 100644 --- a/team.daangn.com/gatsby-node.ts +++ b/team.daangn.com/gatsby-node.ts @@ -12,51 +12,6 @@ export const onPostBootstrap: GatsbyNode['onPostBootstrap'] = ({ }); }; -export const createResolvers: GatsbyNode['createResolvers'] = ({ - createResolvers, - actions: { - createNode, - }, - cache, - createNodeId, -}) => { - createResolvers({ - PrismicLinkField: { - localFileFixed: { - type: 'File', - description: 'See https://github.com/gatsbyjs/gatsby/issues/35636', - resolve(source: any) { - if (!source.url) { - return null; - } - - const url = new URL(source.url); - - let name: string | undefined = undefined; - let ext: string | undefined = undefined; - - const match = url.pathname.match(/\/([^/\\&\?]+)(\.\w{3,4})$/); - if (match) { - name = decodeURIComponent(match[1]); - ext = match[2] ?? undefined; - url.pathname.replace(match[1], name); - url.searchParams.set('_fix35636', 'true'); - } - - return createRemoteFileNode({ - url: url.toString(), - cache, - createNode, - createNodeId, - name, - ext, - }); - }, - }, - }, - }); -}; - export const createPages: GatsbyNode['createPages'] = async ({ graphql, actions, diff --git a/team.daangn.com/src/templates/IrPage.tsx b/team.daangn.com/src/templates/IrPage.tsx index 2f01c172c..2f9e43242 100644 --- a/team.daangn.com/src/templates/IrPage.tsx +++ b/team.daangn.com/src/templates/IrPage.tsx @@ -5,6 +5,7 @@ import { rem } from 'polished'; import { graphql, navigate, + withPrefix, Link, type PageProps, type HeadProps, @@ -32,19 +33,9 @@ export const query = graphql` } attachment_group { file { - #localFile { - # base - # publicURL - #} - # See https://github.com/gatsbyjs/gatsby/issues/35636 - localFileFixed { - - # FIXME - # See https://karrot.atlassian.net/browse/WMAS-46?focusedCommentId=36565 - url - + localFile { base - localURL + publicURL } } } @@ -157,7 +148,7 @@ const IrPage: React.FC = ({ }) => { const ir = prismicData.prismicIr!; const attachments = ir.data.attachment_group - ?.filter(attachment => attachment?.file?.localFileFixed?.localURL) + ?.filter(attachment => attachment?.file?.localFile?.publicURL) ?? []; return ( @@ -210,13 +201,12 @@ const IrPage: React.FC = ({ {attachments.map((attachment, i) => { - const file = attachment!.file!.localFileFixed!; - // const href = withPrefix(file.publicURL!); - const base = decodeURIComponent(stripUUID(file.base)); + const file = attachment!.file!.localFile!; + const href = withPrefix(file.publicURL!); + const base = stripUUID(decodeURIComponent(file.base)); return ( - {/* FIXME: https://karrot.atlassian.net/browse/WMAS-46?focusedCommentId=36565 */} - + {base}