refactor: improve content json importing
This commit is contained in:
parent
a3c0990804
commit
36b1ecd8ec
10 changed files with 43 additions and 28 deletions
|
@ -1,5 +1,5 @@
|
|||
import portfolio from "@developomp-site/content/dist/portfolio.json"
|
||||
import type { PortfolioProject } from "@developomp-site/content/src/types/types"
|
||||
import type { ProjectKey } from "@developomp-site/content/exports/portfolio"
|
||||
import portfolio from "@developomp-site/content/exports/portfolio"
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import Badge from "@/components/Badge"
|
||||
|
@ -12,23 +12,15 @@ function getSkills(): JSX.Element[] {
|
|||
}
|
||||
|
||||
function getProjects(): JSX.Element[] {
|
||||
const projects = []
|
||||
|
||||
for (const projectID in portfolio.projects) {
|
||||
projects.push(
|
||||
return (Object.keys(portfolio.projects) as ProjectKey[]).map(
|
||||
(projectID) => (
|
||||
<ProjectCard
|
||||
key={projectID}
|
||||
projectID={projectID}
|
||||
project={
|
||||
portfolio.projects[
|
||||
projectID as keyof typeof portfolio.projects
|
||||
] as PortfolioProject
|
||||
}
|
||||
project={portfolio.projects[projectID]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return projects
|
||||
)
|
||||
}
|
||||
|
||||
export const metadata: Metadata = {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import "./style.scss"
|
||||
|
||||
import Toc from "@developomp-site/blog/src/app/[category]/[[...slug]]/Toc"
|
||||
import portfolio from "@developomp-site/content/dist/portfolio.json"
|
||||
import type { ProjectKey } from "@developomp-site/content/exports/portfolio"
|
||||
import portfolio from "@developomp-site/content/exports/portfolio"
|
||||
import { faGithub } from "@fortawesome/free-brands-svg-icons"
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||
import { type Metadata } from "next"
|
||||
|
@ -21,14 +22,14 @@ interface Data {
|
|||
}
|
||||
|
||||
interface Params {
|
||||
id: keyof typeof portfolio.projects
|
||||
id: ProjectKey
|
||||
}
|
||||
|
||||
interface Props {
|
||||
params: Params
|
||||
}
|
||||
|
||||
async function getData(id: keyof typeof portfolio.projects): Promise<Data> {
|
||||
async function getData(id: ProjectKey): Promise<Data> {
|
||||
const content = await import(
|
||||
`@developomp-site/content/dist/content/projects/${id}.json`
|
||||
)
|
||||
|
@ -46,9 +47,9 @@ async function getData(id: keyof typeof portfolio.projects): Promise<Data> {
|
|||
}
|
||||
|
||||
export async function generateStaticParams(): Promise<Params[]> {
|
||||
return (
|
||||
Object.keys(portfolio.projects) as (keyof typeof portfolio.projects)[]
|
||||
).map((id) => ({ id }))
|
||||
return (Object.keys(portfolio.projects) as ProjectKey[]).map((id) => ({
|
||||
id,
|
||||
}))
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue