⚠️ This starter is using older version of Next.js SDK and is deprecated in favor of v2.
This starter is based on Next.js App Router but can be used with any other React-based framework.
- Uniform account with an empty project.
-
Install dependencies with
npm install -
Change the API key and Project ID env vars in
.envwith your own.Make sure your API key has "Developer" role to be able to push content.
-
npm run uniform:pushto push content from disk (/uniform-datafolder) to your project. -
Run the development server:
npm run dev
Open http://localhost:3000 with your browser to see the result.
SearchContainer component is a Uniform Component designed to search and filter content effectively. It integrates with Uniform's data model, allowing seamless interaction with content types defined within your Uniform project.
- SearchInput: A simple input field allowing users to input search terms, designed specifically for use within the
SearchContainercomponent. - FilterPanel: A filter panel component that lets users filter search results based on predefined facets, interacting with Uniform facets to apply specific content filters.
- SearchResultCard: Renders individual search results, displaying titles and descriptions to provide a clean visual representation of the search results within the
SearchContainercomponent.
/api/search/route.ts: Handles search functionality by querying the API to retrieve articles based on search terms and filters. It constructs queries and handles the integration with Uniform's backend services.
/uniform/search/client.ts: Contains thegetKnowledgeBaseArticlesfunction, essential for fetching articles from Uniform's backend. It facilitates querying, filtering, and processing articles, using Uniform's API for efficient data retrieval. For more details on working with the search API, developers can refer to Uniform's documentation on search and filtering.
- Search Composition: Configures the search composition where
SearchContainercomponent is used, specifying the setup within Uniform's ecosystem. - [Component Definition](./uniform-data/component/SearchContainer component.yaml): Defines the
SearchContainercomponent in Uniform, specifically itsfilterOptionsparameter, which controls the facets used in the search functionality. Syntax for fields:fieldNameSyntax for reference fields:refFieldName.fieldNameSyntax forSearchContainer component'sfilterOptionsparameter:label:fieldNamewherelabelis the label of the facet in the UI and fieldName is the field on the Article content type that will be used to filter the results. By default uses:Category:category.name,Tags:tags.nameto facetByCategoryandTagsof the Article content type
To create a new SearchComponent that supports other entry types beyond Articles, follow these high-level steps:
-
Define the New Entry Type: Establish the new entry type within your Uniform project, ensuring it's configured with necessary fields and metadata.
-
Clone and Modify SearchContainer component: Copy the
SearchContainercomponent and adapt its logic to interact with the new entry type. Adjust thegetKnowledgeBaseArticlesfunction or create a similar one to query the new data. -
Adjust Atom Components: Update
SearchInput,FilterPanel, andArticleCardto accommodate specific fields or behaviors relevant to the new entry type. Ensure that any data-specific logic is adjusted appropriately. -
Update API Configuration: If necessary, extend or modify existing API routes to cater to the new entry type, focusing on how data is fetched or manipulated.
-
Test and Deploy: Thoroughly test the new component with varying entry types to ensure compatibility and performance, then integrate it into your Uniform project.
This approach maintains scalability and modularity within your Uniform-powered Next.js application, facilitating flexible content management and user interaction.