Skip to content

Commit

Permalink
Merge pull request #67 from yourssu/develop
Browse files Browse the repository at this point in the history
[FEATURE] Sanity 반영 및 푸터 정보 추가
  • Loading branch information
AAminha authored Dec 2, 2024
2 parents 4588884 + 37314a4 commit ec0ff96
Show file tree
Hide file tree
Showing 109 changed files with 1,391 additions and 1,353 deletions.
12 changes: 3 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
"es6": true,
"node": true
},
"plugins": ["react", "jsx-a11y", "prettier", "@typescript-eslint"],
"plugins": ["react", "jsx-a11y", "prettier", "@typescript-eslint", "import"],
"extends": [
"airbnb",
"airbnb-typescript",
"airbnb/hooks",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
Expand All @@ -36,21 +33,18 @@
"index"
],
"pathGroups": [
{
"pattern": "react",
"group": "external",
"position": "before"
},
{
"pattern": "@/**",
"group": "internal",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": ["react", "react-dom"],
"newlines-between": "always",
"alphabetize": { "order": "asc" }
}
],
"react/require-default-props": "off",
"@typescript-eslint/no-use-before-define": 0,
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"react/jsx-props-no-spreading": "off",
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ name: build-and-deploy
on:
push:
branches: [master]
repository_dispatch:
types: [sanity-content-update]

jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: gatsby-build
cancel-in-progress: true
steps:
- name: Checkout source code
uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import "./src/styles/global.css"
import './src/styles/fonts.css';
import './src/styles/global.css';
37 changes: 4 additions & 33 deletions gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,6 @@ const config: GatsbyConfig = {
path: `${__dirname}/src/assets/logo`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
// The unique name for each instance
name: 'social',
// Path to the directory
path: `${__dirname}/src/assets/social/`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
Expand All @@ -121,35 +112,15 @@ const config: GatsbyConfig = {
{
resolve: 'gatsby-source-filesystem',
options: {
// The unique name for each instance
name: 'teams',
// Path to the directory
path: `${__dirname}/src/assets/icons/teams`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
// The unique name for each instance
name: 'department_icons',
// Path to the directory
path: `${__dirname}/src/assets/icons/department_icons`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
// The unique name for each instance
name: 'hovers',
// Path to the directory
path: `${__dirname}/src/assets/icons/hovers`,
name: 'icons',
path: `${__dirname}/src/assets/icons`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'icons',
path: `${__dirname}/src/assets/icons/`,
name: 'socials',
path: `${__dirname}/src/assets/socials`,
},
},
{
Expand Down
211 changes: 177 additions & 34 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { graphql, type GatsbyNode } from 'gatsby';
import { type GatsbyNode } from 'gatsby';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import recruitingSchedule from './src/utils/recruitingSchedule';

interface QueryResult {
allSanityDepartment: {
Expand All @@ -8,15 +9,48 @@ interface QueryResult {
basicInformation: {
name: string;
};
applyProcedure: {
scheduleWithoutAssignment: boolean;
scheduleWithAssignment: boolean;
individualSchedule: boolean;
formSchedule: {
start: Date;
end: Date;
};
procedure: {
step: string;
schedule: string;
}[];
};
};
}[];
};
allSanityRecruitingSchedule: {
scheduleWithAssignment: {
edges: {
node: {
applyProcedure: {
title: string;
formSchedule: {
start: Date;
end: Date;
};
procedure: {
step: string;
schedule: string;
}[];
};
}[];
};
scheduleWithoutAssignment: {
edges: {
node: {
title: string;
formSchedule: {
start: Date;
end: Date;
};
procedure: {
step: string;
schedule: string;
}[];
};
}[];
Expand All @@ -41,87 +75,196 @@ export const createPages: GatsbyNode['createPages'] = async ({
}) => {
const { createPage } = actions;

const queryAllSanityData = await graphql<QueryResult>(`
const result = await graphql<QueryResult>(`
{
allSanityDepartment(sort: { num: ASC }) {
allSanityDepartment(sort: { basicInformation: { key: ASC } }) {
edges {
node {
basicInformation {
name
}
applyProcedure {
scheduleWithoutAssignment
scheduleWithAssignment
individualSchedule
formSchedule {
start
end
}
procedure {
step
schedule
}
}
}
}
}
allSanityRecruitingSchedule {
scheduleWithAssignment: allSanityRecruitingSchedule(
filter: { title: { regex: "/과제 O$/" } }
) {
edges {
node {
applyProcedure {
title
formSchedule {
start
end
}
procedure {
step
schedule
}
}
}
}
scheduleWithoutAssignment: allSanityRecruitingSchedule(
filter: { title: { regex: "/과제 X$/" } }
) {
edges {
node {
title
formSchedule {
start
end
}
procedure {
step
schedule
}
}
}
}
}
`);

if (queryAllSanityData.errors) {
if (result.errors) {
reporter.panicOnBuild(`Error while running query`);
return;
}

const queryAllSanityData = result.data;

const DescriptionTemplateComponent = path.resolve(
__dirname,
'src/templates/DescriptionTemplate.tsx',
);

const nameList = queryAllSanityData.data?.allSanityDepartment.edges.map(
const nameList = queryAllSanityData?.allSanityDepartment.edges.map(
(edge) => edge.node.basicInformation.name,
);

const scheduleContainsAssignment =
queryAllSanityData.data?.allSanityRecruitingSchedule.edges[0].node
.applyProcedure;
const checkRecruitType = (recruitTypeData: {
scheduleWithoutAssignment: boolean;
scheduleWithAssignment: boolean;
individualSchedule: boolean;
formSchedule: {
start: Date;
end: Date;
};
procedure: {
step: string;
schedule: string;
}[];
}): {
formSchedule: { start: Date | null; end: Date | null } | null;
procedure: { step: string; schedule: string }[] | null;
} => {
const {
scheduleWithoutAssignment,
scheduleWithAssignment,
individualSchedule,
formSchedule,
procedure,
} = recruitTypeData;

const recruitingType = {
individualSchedule,
scheduleWithAssignment,
scheduleWithoutAssignment,
};

const scheduleWithAssignmentData =
queryAllSanityData?.scheduleWithAssignment?.edges[0]?.node.formSchedule ||
null;
const scheduleWithoutAssignmentData =
queryAllSanityData?.scheduleWithoutAssignment?.edges[0]?.node
.formSchedule || null;
const scheduleIndividualData = formSchedule || null;

const scheduleWithoutAssignment =
queryAllSanityData.data?.allSanityRecruitingSchedule.edges[
queryAllSanityData.data.allSanityRecruitingSchedule.edges.length - 1
].node.applyProcedure;
const recruitingScheduleData = recruitingSchedule({
recruitingType,
scheduleWithAssignmentData,
scheduleWithoutAssignmentData,
scheduleIndividualData,
});

if (!recruitingScheduleData) {
return {
formSchedule: null,
procedure: null,
};
}

if (recruitingScheduleData.type === 'individual') {
return {
formSchedule: recruitingScheduleData.formSchedule,
procedure: procedure,
};
}

if (recruitingScheduleData.type === 'withAssignment') {
return {
formSchedule: recruitingScheduleData.formSchedule,
procedure:
queryAllSanityData?.scheduleWithAssignment?.edges[0]?.node
.procedure || [],
};
}

if (recruitingScheduleData.type === 'withoutAssignment') {
return {
formSchedule: recruitingScheduleData.formSchedule,
procedure:
queryAllSanityData?.scheduleWithoutAssignment?.edges[0]?.node
.procedure || [],
};
}

return {
formSchedule: null,
procedure: null,
};
};

const generateDescriptionPage = ({
node: {
basicInformation: { name },
},
name,
recruiting,
}: {
node: {
basicInformation: {
name: string;
};
name: string;
recruiting: {
formSchedule: { start: Date | null; end: Date | null } | null;
procedure: { step: string; schedule: string }[] | null;
};
}) => {
const pathName = name.toLowerCase().replaceAll(' ', '_');
const teamNamesContainsAssignmentInSchedule = [
'backend_developer',
'product_designer',
];

const pageOptions = {
path: `recruiting/${pathName}`,
component: DescriptionTemplateComponent,
context: {
name,
nameList,
schedule: teamNamesContainsAssignmentInSchedule.includes(pathName)
? scheduleContainsAssignment
: scheduleWithoutAssignment,
formSchedule: recruiting.formSchedule,
procedure: recruiting.procedure,
},
};

createPage(pageOptions);
};

queryAllSanityData.data &&
queryAllSanityData.data.allSanityDepartment.edges.forEach(
generateDescriptionPage,
);
queryAllSanityData?.allSanityDepartment.edges.forEach((data) => {
generateDescriptionPage({
name: data.node.basicInformation.name,
recruiting: checkRecruitType(data.node.applyProcedure),
});
});
};
Loading

0 comments on commit ec0ff96

Please sign in to comment.