Skip to content

Commit

Permalink
[WMAS-46] remove temporal patch code for file downloading
Browse files Browse the repository at this point in the history
See gatsbyjs/gatsby#35636
Resolves [WMAS-46]
  • Loading branch information
cometkim committed Feb 21, 2023
1 parent f688fe2 commit 6758b44
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
45 changes: 0 additions & 45 deletions team.daangn.com/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 8 additions & 18 deletions team.daangn.com/src/templates/IrPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { rem } from 'polished';
import {
graphql,
navigate,
withPrefix,
Link,
type PageProps,
type HeadProps,
Expand Down Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -157,7 +148,7 @@ const IrPage: React.FC<IrPageProps> = ({
}) => {
const ir = prismicData.prismicIr!;
const attachments = ir.data.attachment_group
?.filter(attachment => attachment?.file?.localFileFixed?.localURL)
?.filter(attachment => attachment?.file?.localFile?.publicURL)
?? [];

return (
Expand Down Expand Up @@ -210,13 +201,12 @@ const IrPage: React.FC<IrPageProps> = ({
</AttachmentSectionTitle>
<FileList>
{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 (
<FileListItem key={i}>
{/* FIXME: https://karrot.atlassian.net/browse/WMAS-46?focusedCommentId=36565 */}
<File href={file!.url} download={base}>
<File href={href} download={base}>
{base}
</File>
</FileListItem>
Expand Down

0 comments on commit 6758b44

Please sign in to comment.