-
-
Notifications
You must be signed in to change notification settings - Fork 35
Development #77
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
Development #77
Conversation
- Bump versions for several Radix UI components and Tailwind CSS packages. - Update Next.js to version 15.3.0. - Upgrade TypeScript and ESLint packages. - Update rehype and remark packages for improved functionality. refactor: enhance MDX file processing in content.ts - Optimize content processing by removing code blocks and formatting links. - Introduce search optimization by cleaning up content and extracting headings. - Add _searchMeta to return structured search data including clean content and keywords.
- Introduced a new function `cleanContentForSearch` to sanitize and format content for better searchability. - Removed inline code blocks, markdown formatting, and unnecessary whitespace from the content. - Extracted headings and keywords from the document for improved search metadata. - Updated the `_searchMeta` object to include cleaned content, headings, and unique keywords.
…unction - Added new custom components to be removed: Card, CardGrid, Step, StepItem, Note, FileTree, Folder, and File. - Improved regex replacements for code blocks, inline code, and headings. - Enhanced handling of tables by trimming whitespace from cells. - Consolidated removal of custom components into a single regex pattern. - Cleaned up whitespace and punctuation handling for better content normalization.
…build-register dependency
- Adjusted class order in various components for consistency and readability. - Updated layout and spacing in error, not found, and home pages for better alignment. - Enhanced card component styles for improved hover effects and layout. - Refined navigation components for better accessibility and visual hierarchy. - Improved search component layout and responsiveness. - Cleaned up utility functions and markdown processing for better performance and readability. - Updated ESLint and Prettier configurations for improved code quality and consistency.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Reviewer's Guide by SourceryThis pull request includes updates to documentation, configuration, code style, and search functionality. It adds badges to the README, removes the Prettier configuration, improves search relevance and snippet extraction, updates content processing, and adjusts class names for better readability and consistency across multiple components and pages. Updated Class Diagram for SearchDocumentclassDiagram
class SearchDocument {
slug: string
title: string
content: string
description: string
_searchMeta: SearchMeta
}
class SearchMeta {
cleanContent: string
headings: string[]
keywords: string[]
}
SearchDocument -- SearchMeta : has a
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 37 out of 38 changed files in this pull request and generated no comments.
Files not reviewed (1)
- .prettierrc: Language not supported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rubixvi - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a changeset to track the removal of the
.prettierrc
file. - The changes to
lib/utils.ts
significantly alter the search algorithm; ensure these changes are thoroughly tested.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 2 issues found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -139,54 +153,68 @@ function searchMatch(a: string, b: string): number { | |||
function calculateRelevance( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider extracting helper functions and precomputing lowercased versions of content to reduce repeated looping and lowercasing in the calculateRelevance function, improving efficiency and readability without changing functionality
Consider extracting helper functions to remove repeated looping and repeated lowercasing. For example, you can precompute a lowercased version of content and factor out the scoring of list matches into a helper. One approach might be:
```typescript
function scoreListMatches(
items: string[],
target: string,
exactScore: number,
includeScore: number
): number {
let score = 0;
if (items.some((item) => item === target)) score += exactScore;
items.forEach((item) => {
if (item.includes(target)) score += includeScore;
});
return score;
}
function calculateRelevance(
query: string,
title: string,
content: string,
headings: string[],
keywords: string[]
): number {
const lowerQuery = query.toLowerCase().trim();
const lowerTitle = title.toLowerCase();
const lowerContent = content.toLowerCase();
const queryWords = lowerQuery.split(/\s+/);
let score = 0;
if (lowerTitle === lowerQuery) {
score += 50;
} else if (lowerTitle.includes(lowerQuery)) {
score += 30;
}
queryWords.forEach((word) => {
if (lowerTitle.includes(word)) score += 15;
});
// Pre-lower headings and keywords
const lowerHeadings = headings.map((h) => h.toLowerCase());
const lowerKeywords = keywords.map((k) => k.toLowerCase());
score += scoreListMatches(lowerHeadings, lowerQuery, 40, 25);
score += scoreListMatches(lowerKeywords, lowerQuery, 35, 20);
const exactMatches = lowerContent.match(new RegExp(`\\b${lowerQuery}\\b`, "gi"));
if (exactMatches) score += exactMatches.length * 10;
queryWords.forEach((word) => {
if (lowerContent.includes(word)) score += 5;
});
const proximityScore = calculateProximityScore(lowerQuery, lowerContent);
score += proximityScore * 2;
return score / Math.log(content.length + 1);
}
This refactoring consolidates similar logic, reduces redundant operations, and makes future modifications easier to manage without changing functionality.
@@ -95,18 +104,74 @@ function removeCustomComponents() { | |||
} | |||
} | |||
|
|||
function cleanContentForSearch(content: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider refactoring the regex chain in cleanContentForSearch
into a sequence of smaller, well-named transformation functions for improved readability and maintainability.
Consider refactoring the inline regex chain into a sequence of small, well-named transformation functions. This makes each step self-contained and easier to debug. For example:
function removeCodeBlocks(text: string): string {
return text.replace(/```[\s\S]*?```/g, " ");
}
function inlineCode(text: string): string {
return text.replace(/`([^`]+)`/g, "$1");
}
function removeHeadings(text: string): string {
return text.replace(/#{1,6}\s+(.+)/g, "$1");
}
function unwrapMarkdownLinks(text: string): string {
return text.replace(/\[([^\]]+)\]\([^\)]+\)/g, "$1");
}
// Define other transformations as needed...
function cleanContentForSearch(content: string): string {
const transformations = [
removeCodeBlocks,
inlineCode,
removeHeadings,
unwrapMarkdownLinks,
// ...other helper functions
];
return transformations.reduce((text, fn) => fn(text), content)
// example final adjustments:
.replace(/[^\w\s-:]/g, " ")
.replace(/\s+/g, " ")
.toLowerCase()
.trim();
}
This refactoring maintains functionality while making the logic clearer and easier to extend or modify in the future.
Merge pull request #77 from rubixvi/development
This pull request includes various updates across multiple files to improve code style consistency, enhance documentation, and fix minor layout issues. The most important changes include updates to the
README.md
, removal of the.prettierrc
configuration, and several class name adjustments for better readability and consistency.Documentation Updates:
README.md
: Added several badges for license, top language, commit activity, last commit, issues, pull requests, stars, forks, and repo size. Removed the documentation link that was in development. [1] [2]Configuration Removal:
.prettierrc
: Removed the Prettier configuration file entirely.Code Style Improvements:
app/docs/[[...slug]]/page.tsx
: Adjusted class names for better readability and consistency, including changes toh1
,p
, andsection
elements. (app/docs/[[...slug]]/page.tsxL33-R43)app/error.tsx
: Updated class names to improve readability.app/layout.tsx
: Modified class names for better readability.app/not-found.tsx
: Adjusted class names for better readability and consistency.app/page.tsx
: Updated class names for better readability and consistency. [1] [2]Component Updates:
components/markdown/card.tsx
: Adjusted class names for better readability and consistency in theCard
andCardGrid
components. [1] [2] [3]components/navigation/footer.tsx
: Updated class names for better readability. [1] [2]components/navigation/navbar.tsx
: Modified class names for better readability and consistency.Summary by Sourcery
Refactor and improve code style, documentation, and search functionality across the project
Enhancements:
Build:
Documentation:
Chores: