added localization to portfolio page

This commit is contained in:
Kim, Jimin 2022-03-27 10:40:59 +09:00
parent 4646eb478f
commit 4228eb097f
5 changed files with 33 additions and 12 deletions

View file

@ -28,7 +28,8 @@ export const map: Map = {
} }
export const seriesMap: SeriesMap = {} export const seriesMap: SeriesMap = {}
export const portfolioData: PortfolioData = { export const portfolioData: PortfolioData = {
overview: "", overview_en: "",
overview_kr: "",
skills: new Set(), skills: new Set(),
projects: {}, projects: {},
} }

View file

@ -9,12 +9,14 @@ import { portfolioData } from ".."
import { DataToPass } from "." import { DataToPass } from "."
export default function parsePortfolio(data: DataToPass): void { export default function parsePortfolio(data: DataToPass): void {
const { urlPath, markdownRaw, markdownData } = data const { urlPath, markdownRaw, markdownData, path } = data
// check if the file is a portfolio overview or a project // check if the file is a portfolio overview or a project
// explanation: file `0.md` is a special file (i.e. not a regular project file) // explanation: file `0.md` is a special file (i.e. not a regular project file)
if (urlPath.slice(urlPath.lastIndexOf("/") + 1) == "0") { if (path.endsWith("/0.md")) {
portfolioData.overview = markdownData.content portfolioData.overview_en = markdownData.content
} else if (path.endsWith("/0.kr.md")) {
portfolioData.overview_kr = markdownData.content
} else { } else {
if (!urlPath.endsWith(".kr")) { if (!urlPath.endsWith(".kr")) {
if (markdownData.badges) { if (markdownData.badges) {

View file

@ -0,0 +1,7 @@
## 교육
현재 [홍익대학교](https://wwwce.hongik.ac.kr) 컴퓨터공학과에 진학중.
## 기술
<img alt="programming skills" src="/img/skills.svg" style="display: block; margin-left: auto; margin-right: auto; max-width: 100%;" />

View file

@ -1,15 +1,20 @@
import { useEffect, useState } from "react" import { useContext, useEffect, useState } from "react"
import { Helmet } from "react-helmet-async" import { Helmet } from "react-helmet-async"
import MainContent from "../../components/MainContent" import MainContent from "../../components/MainContent"
import ProjectCard from "./ProjectCard"
import Badge from "../../components/Badge" import Badge from "../../components/Badge"
import ProjectCard from "./ProjectCard"
import portfolio from "../../data/portfolio.json" import portfolio from "../../data/portfolio.json"
import { PortfolioProject } from "../../../types/types" import { globalContext } from "../../globalContext"
import type { PortfolioProject } from "../../../types/types"
const Portfolio = () => { const Portfolio = () => {
const { globalState } = useContext(globalContext)
const locale = globalState.locale
const [projects, setProjects] = useState<JSX.Element[]>([]) const [projects, setProjects] = useState<JSX.Element[]>([])
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
const [skills, setSkills] = useState<JSX.Element[]>([]) const [skills, setSkills] = useState<JSX.Element[]>([])
@ -43,7 +48,7 @@ const Portfolio = () => {
return ( return (
<> <>
<Helmet> <Helmet>
<title>pomp | Portfolio</title> <title>pomp | {locale == "en" ? "Portfolio" : "포트폴리오"}</title>
<meta property="og:title" content="Portfolio" /> <meta property="og:title" content="Portfolio" />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
@ -56,13 +61,18 @@ const Portfolio = () => {
</Helmet> </Helmet>
<MainContent> <MainContent>
<h1>Portfolio</h1> <h1>{locale == "en" ? "Portfolio" : "포트폴리오"}</h1>
<hr /> <hr />
{/* rendered markdown */} {/* rendered markdown */}
<div dangerouslySetInnerHTML={{ __html: portfolio.overview }} /> <div
dangerouslySetInnerHTML={{
__html:
locale == "en" ? portfolio.overview_en : portfolio.overview_kr,
}}
/>
{/* Projects */} {/* Projects */}
@ -70,7 +80,7 @@ const Portfolio = () => {
<a className="header-anchor" href="#projects"> <a className="header-anchor" href="#projects">
# #
</a>{" "} </a>{" "}
Projects {locale == "en" ? "Projects" : "프로젝트"}
</h2> </h2>
{/* todo: filter projects by skill */} {/* todo: filter projects by skill */}

View file

@ -111,7 +111,8 @@ export interface SeriesEntry {
export interface PortfolioData { export interface PortfolioData {
// rendered markdown html // rendered markdown html
overview: string overview_en: string
overview_kr: string
// a set of valid simple icons slug // a set of valid simple icons slug
skills: Set<string> skills: Set<string>