Skip to content

Feature/media page filters #738

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

Merged
merged 2 commits into from
Jun 8, 2025
Merged

Conversation

jeromehardaway
Copy link
Contributor

This pull request introduces a new "Media" section to the application, including backend data handling, a new component for displaying media items, and comprehensive test coverage. The most important changes are grouped into the following themes:

Media Functionality Implementation:

  • Added MediaCard component (src/components/media-card/index.tsx) to display individual media items with details like title, media type, publication, and date. The component supports external links and includes hover effects.
  • Introduced getAllMediaPosts utility function in src/lib/mdx-pages.ts to fetch and process media data from the src/data/media directory.

Media Data and Content:

  • Added new media content files, such as vwc-bridging-the-gap-huffpost.mdx and vwc-tech-forward-podcast-2021.mdx, to the src/data/media directory, providing sample media items for the "Media" section. [1] [2]
  • Included a .gitkeep file in src/data/media/ to ensure the directory is tracked by Git.

Navigation and Routing:

  • Updated src/data/menu.ts to add a "Media" link to the navigation menu, ensuring users can access the new section.

Testing:

  • Added comprehensive tests for the MediaPage in __tests__/pages/media.tests.tsx, covering functionality like filtering by media type, year, and search term, as well as resetting filters.

google-labs-jules bot and others added 2 commits June 7, 2025 23:21
This commit enhances the Media Page by adding functionality to filter
media items by type and year, and to search by keywords.

Key improvements include:
- Added filter dropdowns for 'Media Type' and 'Year' to `src/pages/media.tsx`.
- Implemented a search input field for keyword searching across title,
  description, and publication.
- Developed client-side logic to filter media items based on the
  selected criteria.
- Dynamically populates filter dropdown options from the available media items,
  with years sorted descending and media types sorted alphabetically.
- Added a 'Reset' button to clear all active filters and search terms.
- Refined the styling of the filter controls section for better visual
  grouping and user experience, ensuring theme consistency.
- Included comprehensive tests in `__tests__/pages/media.tests.tsx`
  to cover the new filtering and searching capabilities, ensuring
  robustness and easier maintenance.

These enhancements significantly improve the usability of the Media Page,
allowing users to more easily find specific media mentions.
@jeromehardaway jeromehardaway requested a review from Copilot June 8, 2025 00:35
@jeromehardaway jeromehardaway self-assigned this Jun 8, 2025
Copy link

vercel bot commented Jun 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vets-who-code-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 8, 2025 0:37am

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new Media section, complete with data fetching, UI, and tests to display and filter media items.

  • Defines an IMedia type and getAllMediaPosts utility to load front-matter from MDX files.
  • Implements MediaPage with dropdown filters, search, reset functionality, and MediaCard UI component.
  • Adds sample MDX media posts, updates navigation menu, and introduces comprehensive filtering tests.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utils/types.ts Introduced IMedia interface for media item shape
src/lib/mdx-pages.ts Added getAllMediaPosts to read media front-matter
src/pages/media.tsx Created MediaPage with filter/search UI and getStaticProps
src/components/media-card/index.tsx Built MediaCard component for rendering individual items
src/data/menu.ts Added “Media” link to site navigation
src/data/media/*.mdx Sample media posts for Podcast and Article entries
tests/pages/media.tests.tsx Tests covering filtering by type, year, search, and reset button
Comments suppressed due to low confidence (4)

src/pages/media.tsx:177

  • getStaticProps returns a layout prop, but TProps for MediaPage doesn’t define layout. Add a layout type to TProps or remove it to align with the component signature.
layout: { headerShadow: true, headerFluid: false, footerMode: "light" },

src/components/media-card/index.tsx:42

  • [nitpick] For consistency, consider using the imported Anchor component for the title link instead of a raw <a>, to unify link styling and behavior.
<a href={url} target="_blank" rel="noopener noreferrer" className="hover:tw-text-primary">

tests/pages/media.tests.tsx:30

  • The test mocks getallPosts but the module exports getAllMediaPosts. The mock won’t override the correct function; update the mock key to getAllMediaPosts.
jest.mock("@lib/mdx-pages", () => ({ getallPosts: () => mockGetAllPosts(), }));

src/lib/mdx-pages.ts:22

  • The file list isn’t sorted, which can lead to non-deterministic ordering of media items. Consider sorting files (e.g., alphabetically or by date) before mapping.
const files = fs.readdirSync(directory)

};
description?: string;
// any other fields that might come from frontmatter
[key: string]: any; // To allow for other frontmatter fields
Copy link
Preview

Copilot AI Jun 8, 2025

Choose a reason for hiding this comment

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

The index signature using any undermines type safety. Consider using unknown or a more specific type instead of any.

Suggested change
[key: string]: any; // To allow for other frontmatter fields
[key: string]: unknown; // To allow for other frontmatter fields

Copilot uses AI. Check for mistakes.

type="text"
id="searchTerm"
name="searchTerm"
className="appearance-none h-12 py-3 text-base tw-mt-1 tw-block tw-w-full tw-rounded-md tw-border-gray-300 tw-py-3 tw-pl-3 tw-pr-10 focus:tw-border-primary focus:tw-outline-none focus:tw-ring-primary sm:tw-text-sm"
Copy link
Preview

Copilot AI Jun 8, 2025

Choose a reason for hiding this comment

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

The className includes both py-3 and tw-py-3, likely a typo. Remove the unprefixed py-3 to avoid inconsistent styling.

Suggested change
className="appearance-none h-12 py-3 text-base tw-mt-1 tw-block tw-w-full tw-rounded-md tw-border-gray-300 tw-py-3 tw-pl-3 tw-pr-10 focus:tw-border-primary focus:tw-outline-none focus:tw-ring-primary sm:tw-text-sm"
className="appearance-none h-12 text-base tw-mt-1 tw-block tw-w-full tw-rounded-md tw-border-gray-300 tw-py-3 tw-pl-3 tw-pr-10 focus:tw-border-primary focus:tw-outline-none focus:tw-ring-primary sm:tw-text-sm"

Copilot uses AI. Check for mistakes.

@jeromehardaway jeromehardaway merged commit c1d00fe into master Jun 8, 2025
4 checks passed
@jeromehardaway jeromehardaway deleted the feature/media-page-filters branch June 8, 2025 00:42
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.

1 participant