1

I'm using gray-matter/frontMatter and remark-mdx to read values of an .mdx file in a nextJS project:

.mdx file:

details:
  - pronoun: she/her
  - favoriteThing: learning
  - leastFavoriteThing: winter
  - favoriteMovie: kiki's delivery service
  - hatedBird: crows
  - hobby: mountain biking
  - personalAesthetic: uncool millennial
  - signs:
      - sun: leo
      - rising: sagittarius
      - moon: capricorn

[slug].tsx:

  function Details() {
    return (
        <div>
          {details.map((s) => {
            return (
              <div>
                <h1>
                  {CamelCaseToSentence(Object.keys(s).toString())}
                </h1>
                {Object.keys(s).toString() === 'signs' ? (
                  <ul>
                    <li>☉ {frontMatter.details.signs}</li>
                    <li>↑ {frontMatter.details.signs.rising}</li>
                    <li>☽ {frontMatter.details.signs.moon}</li>
                  </ul>
                ) : (
                  <p>{Object.values(s).toString()}</p>
                )}
              </div>
            )
          })}
      </div>
    )
  }

The file can read everything except for the double nested values of Signs and throws an 'undefined' error. How do I map out the double-nested values? I've tried everything.

vldmrrdjcc
  • 2,082
  • 5
  • 22
  • 41
  • _"throws an 'undefined' error"_ - What line specifically is throwing the error? Also, if you log `details` to the console, what's the output? – juliomalves Jul 17 '22 at 17:55

0 Answers0