Skip to content

Commit

Permalink
[WMAS-39] IR 페이지 추가 (#589)
Browse files Browse the repository at this point in the history
* wip

* ir 페이지 작업

* ir.daangn.com 사이트 리디렉션 추가

* 페이지 타이틀 추가
  • Loading branch information
cometkim authored May 12, 2022
1 parent f889c99 commit 2a93224
Show file tree
Hide file tree
Showing 17 changed files with 595 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ const List = styled(motion.ul, {
const JobPostLink = styled(Link, {
display: 'block',
color: 'inherit',
transition: 'color .3s',
textDecoration: 'none',
'@media not (prefers-reduced-motion: reduce)': {
transition: 'color .3s',
},
'&:hover': {
color: vars.$scale.color.gray600,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import _Header from '@karrotmarket/gatsby-theme-website/src/components/Header';
import _Footer from '@karrotmarket/gatsby-theme-website/src/components/Footer';
import { useTranslation } from '@karrotmarket/gatsby-plugin-lokalise-translation/src/translation';

import { usePrefersColorScheme } from '../utils/usePreferColorScheme';

type DefaultLayoutProps = OverrideProps<
PageProps<GatsbyTypes.TeamWebsite_DefaultLayout_queryFragment>,
{
Expand Down Expand Up @@ -78,14 +76,22 @@ const DefaultLayout: React.FC<DefaultLayoutProps> = ({
data,
children,
}) => {
try {
required(data.prismicSiteNavigation);
required(data.prismicTeamContents?.data);
} catch {
return (
<div id="layout">
{children}
</div>
);
}

const messages = useTranslation();

const siteOrigin = useSiteOrigin();
const { pathname: currentPath } = useLocation();

required(data.prismicSiteNavigation);
required(data.prismicTeamContents?.data);

return (
<>
<Helmet>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import type { PageProps } from 'gatsby';
import { navigate } from 'gatsby';
import { } from 'gatsby';
import { rem } from 'polished';
import { motion, AnimateSharedLayout } from 'framer-motion';
import { graphql, Link } from 'gatsby';
import { graphql, navigate, Link } from 'gatsby';
import { styled } from 'gatsby-theme-stitches/src/config';
import { GatsbySeo } from 'gatsby-plugin-next-seo';
import type { OverrideProps } from '@cometjs/core';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,6 @@ const LayoutSwitch: React.FC<LayoutSwitchProps> = ({

const { pathname: path } = useLocation();

if (path === '/') {
return (
<DefaultLayout {...props}>
{children}
</DefaultLayout>
);
}

if (/\/jobs\/faq\/?$/.test(path)) {
return (
<DefaultLayout {...props}>
{children}
</DefaultLayout>
);
}

if (/\/jobs\/\d+\/?/.test(path)) {
return (
<DefaultLayout {...props}>
Expand All @@ -81,31 +65,11 @@ const LayoutSwitch: React.FC<LayoutSwitchProps> = ({
);
}

if (/\/jobs\/.+\/?/.test(path)) {
return (
<DefaultLayout {...props}>
{children}
</DefaultLayout>
);
}

if (/\/faq\/.+\/?/.test(path)) {
return (
<DefaultLayout {...props}>
{children}
</DefaultLayout>
);
}

if (/\/(jobs|preview|culture|faq)\/?/.test(path)) {
return (
<DefaultLayout {...props}>
{children}
</DefaultLayout>
);
}

return <>{children}</>;
return (
<DefaultLayout {...props}>
{children}
</DefaultLayout>
);
}

export default LayoutSwitch;
88 changes: 43 additions & 45 deletions _packages/@karrotmarket/gatsby-theme-team-website/src/pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { styled } from 'gatsby-theme-stitches/src/config';
import { GatsbySeo } from 'gatsby-plugin-next-seo';
import { mapLink, useLinkParser } from '@karrotmarket/gatsby-theme-website/src/link';
import { required } from '@cometjs/core';
import DefaultLayout from '../layouts/DefaultLayout';
import ButtonLink from '../components/Button';

import { withPrismicUnpublishedPreview } from 'gatsby-plugin-prismic-previews';
Expand Down Expand Up @@ -70,54 +69,53 @@ const Control = styled('div', {
},
});

const NotFoundPage: React.FC<NotFoundPageProps> = pageProps => {
const { data } = pageProps;
const parseLink = useLinkParser();

const NotFoundPage: React.FC<NotFoundPageProps> = ({
data,
}) => {
required(data.prismicTeamContents?.data);

const parseLink = useLinkParser();

return (
<DefaultLayout {...pageProps}>
<Container>
<GatsbySeo noindex nofollow />
<Container>
<Title>
{data.prismicTeamContents.data.notfound_page_title.text}
</Title>
<Illustration />
<Control>
{data.prismicTeamContents.data.notfound_page_link_group
.map((entry, i) => {
const link = parseLink(entry.link.url);
return mapLink(link, {
Internal: link => (
<ButtonLink
key={i}
to={link.pathname}
type={i === 0 ? 'primary' : 'default'}
fullWidth={{ initial: true, '@sm': false }}
>
{entry.display_text}
</ButtonLink>
),
External: link => (
<ButtonLink
as="a"
target="_blank"
rel="external noopener"
key={i}
href={link.url.href}
type={i === 0 ? 'primary' : 'default'}
fullWidth={{ initial: true, '@sm': false }}
>
{entry.display_text}
</ButtonLink>
),
});
})
}
</Control>
</Container>
</DefaultLayout>
<Title>
{data.prismicTeamContents.data.notfound_page_title.text}
</Title>
<Illustration />
<Control>
{data.prismicTeamContents.data.notfound_page_link_group
.map((entry, i) => {
const link = parseLink(entry.link.url);
return mapLink(link, {
Internal: link => (
<ButtonLink
key={i}
to={link.pathname}
type={i === 0 ? 'primary' : 'default'}
fullWidth={{ initial: true, '@sm': false }}
>
{entry.display_text}
</ButtonLink>
),
External: link => (
<ButtonLink
as="a"
target="_blank"
rel="external noopener"
key={i}
href={link.url.href}
type={i === 0 ? 'primary' : 'default'}
fullWidth={{ initial: true, '@sm': false }}
>
{entry.display_text}
</ButtonLink>
),
});
})
}
</Control>
</Container>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
declare module '*.svg' {
import type * as React from 'react';

interface SvgrComponent extends React.StatelessComponent<React.SVGAttributes<SVGElement>> {}

const url: string;
Expand Down
9 changes: 9 additions & 0 deletions ir.daangn.com/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"redirects": [
{
"source": "/(.*)",
"destination": "https://team.daangn.com/ir/",
"permanent": false
}
]
}
105 changes: 105 additions & 0 deletions team.daangn.com/gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as path from 'path';
import type { GatsbyNode } from 'gatsby';
import { createRemoteFileNode } from 'gatsby-source-filesystem';

export const onCreateBabelConfig: GatsbyNode['onCreateBabelConfig'] = ({
actions,
Expand All @@ -20,3 +22,106 @@ export const onPostBootstrap: GatsbyNode['onPostBootstrap'] = ({
isPermanent: true,
});
};

export const createResolvers: GatsbyNode['createResolvers'] = ({
createResolvers,
actions: {
createNode,
},
store,
cache,
reporter,
createNodeId,
}) => {
createResolvers({
PrismicLinkType: {
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,
store,
reporter,
name,
ext,
});
},
},
},
});
};

export const createPages: GatsbyNode['createPages'] = async ({
graphql,
actions,
reporter,
store,
}) => {
const { program } = store.getState();
const basePath = program.directory as string;

const gql = String.raw;

type Data = {
allPrismicIr: {
nodes: Array<{
uid: string,
}>,
},
};
const { data, errors } = await graphql<Data>(gql`
{
allPrismicIr(
filter: {
uid: {
ne: null
}
tags: {
in: ["team.daangn.com"]
}
}
) {
nodes {
uid
}
}
}
`);

if (errors) {
reporter.panicOnBuild(errors);
}

console.log(data);

for (const ir of data.allPrismicIr.nodes) {
actions.createPage({
path: `/ir/${ir.uid}/`,
component: path.resolve(basePath, 'src/templates/IrPage.tsx'),
context: {
uid: ir.uid,
},
});
}
};
1 change: 1 addition & 0 deletions team.daangn.com/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@karrotmarket/gatsby-source-greenhouse-jobboard": "0.6.0",
"@karrotmarket/gatsby-theme-team-website": "workspace:^",
"@karrotmarket/gatsby-transformer-job-post": "workspace:^",
"@seed-design/design-token": "alpha",
"cjk-slug": "0.3.0",
"gatsby": "4.14.0",
"gatsby-plugin-advanced-sitemap": "2.1.0",
Expand Down
Loading

1 comment on commit 2a93224

@vercel
Copy link

@vercel vercel bot commented on 2a93224 May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ir-daangn-com – ./

ir-daangn-com-karrot.vercel.app
ir-daangn-com-git-main-karrot.vercel.app
ir-daangn-com.vercel.app

Please sign in to comment.