The comments list feature could be added to the system by performing the following steps:
- Create a repository interface, ICommentRepository.
- Create a repository object, CommentRepository.
- Create a query object interface, IGetCommentsByPostQuery.
- Create a concrete query object, GetCommentsByPostQuery.
- Configure the CommentRepository injection in the Startup file.
- Create a View component, CommentsListViewComponent.
- Create a View, Default.cshtml, under Shared | Components | CommentsList.
- Include the current library in the _ViewImports.cshtml to support the custom tag helper.
- Add components using the custom tag helper, <vc:comments>.
The preceding listed implementation is performed and available in the following Git repository commit:
The View component rendering of the comments list is displayed in the following screenshot:
The comments list that gets rendered using the View component in the anonymous blog is displayed in the following screenshot:
We have seen the changes required to include Post comments to the system. In the next section, let's focus on how comments are added.