Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract Content in to JSON files #28

Open
George-Madeley opened this issue Mar 6, 2024 · 0 comments
Open

Abstract Content in to JSON files #28

George-Madeley opened this issue Mar 6, 2024 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@George-Madeley
Copy link
Collaborator

Abstract Content into JSON Files

Problem

All of the text on the website is cluttering up the code making it hard to understand and debug. This needs to be fixed.

Solution

We can move the text (not the HTML tags) into JSON files then import those json files into the TSX and access those object attributes like a normal object. This cleans up the code massively. Examples can be seen below:

JSON File:

{
    "introduction": [
        "Over the years, I have developed a passion for ...",
        "The following section is a ..."
    ],
    ...
}

Then the TSX file where we import the JSON file contents:

import json from '../../data/about_page.real.json'

export default function AboutPage() {
  return (
    <div className='about-page'>
      <Heading>
        <div className='heading-content'>
          <h1>About Me</h1>
        </div>
      </Heading>
      <Description content={json.introduction} />
      <Timeline content={json.experiences} />
    </div>
  )
}
@George-Madeley George-Madeley added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants