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

+Add support for multiple sections #48

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

diiigle
Copy link

@diiigle diiigle commented Oct 26, 2023

Fix for #21

Started with Projects and will port the same mechanism to the other sections as well. But feel free to give some feedback already, especially on the typescript best practices (got virtually 0 experience there)!

Summary

It queries for File nodes instead of specific *Json nodes now, and filters inside the component. Not ideal (the filtering could happen in graphql already), but that its the only way possible with staticQueries (and without variables).

Updated the documentation to the best of my knowledge. The example content could be a lot more creative.

Progress

  • About
  • Contact
  • Hero
  • Interests
  • Legal already contains a filtering mechanism
  • Projects

@diiigle diiigle marked this pull request as ready for review October 30, 2023 16:34
Copy link
Owner

@konstantinmuenster konstantinmuenster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @diiigle – really appreciated! I left a comment. Would be great if we can improve this before merging 👍

Comment on lines +11 to +16
const allFiles = response.allFile.aboutFiles;
const fileNameNeedle = props.fileName ? props.fileName : 'about';
const result = allFiles.find((file) => {
return file.name == fileNameNeedle;
});
const section = result ? result.section[0] : allFiles[0].section[0];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great if we could abstract this away + add null checking and error messages for unknown sections. For example, for the Legal sections, we did:

const data = getSectionBySectionId(response, props.sectionId);

and handled the data part entirely in Legal/data.tsx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants