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

fix: update Twitter URL and improve functionality/fix: resolved various data and calculation errors #996

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

Conversation

sergeypanin1994
Copy link

fix: update Twitter URL and improve functionality

  • Updated Twitter URL to reflect rebranding to x.com format
  • Enhanced social card generation and MDX file processing
    • Improved sanitizeSlug function to support Unicode and clean special characters
    • Fixed splitTitleIntoLines logic to prevent text loss
    • Added template image validation before processing in generateSocialCard
    • Improved error handling and logging for better debugging
  • Optimized MDX file processing for efficient changes
  • Improved directory handling with recursive subdirectory processing

fix: resolved various data and calculation errors

  • Fixed calculateDailyIncrease time range calculation
  • Added check for values.length < 2 in daily increase computation
  • Corrected totalSize handling to avoid empty data errors
  • Improved axios request error handling and added API response validation
  • Fixed getWeekNumber logic for accurate week number calculation
  • Improved JSON file handling to prevent data corruption
  • Added additional logging for better diagnostics

Node size data is now processed and saved correctly.

- Fixed an issue in `calculateDailyIncrease`, ensuring correct time range calculation
- Added a check for `values.length < 2` before computing daily increase
- Fixed `totalSize` handling to avoid errors with empty data
- Improved error handling for `axios` requests
- Added API response format validation to prevent failures
- Fixed `getWeekNumber` logic for correct week number calculation
- Improved JSON file handling to prevent overwriting with corrupted data
- Added additional logs for better error diagnostics

Node size data is now processed and saved correctly.
- Enhanced `sanitizeSlug` function to support Unicode and properly clean special characters
- Fixed `splitTitleIntoLines` logic to prevent text loss and improve line splitting
- Added validation to check if the template image exists before processing (`generateSocialCard`)
- Improved error handling and logging for better debugging
- Optimized MDX file processing by ensuring changes are written only when necessary
- Improved directory processing to recursively handle all subdirectories
Updated the Twitter URL from https://twitter.com to https://x.com to reflect the platform's rebranding.
Copy link

vercel bot commented Feb 18, 2025

@sergeypanin1994 is attempting to deploy a commit to the Consensys Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Collaborator

@jlwllmr jlwllmr left a comment

Choose a reason for hiding this comment

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

Thanks @sergeypanin1994. Just the one thing to catch — TIL how week numbering works 😅

I'll tag in @sammysango to take a look at the social card function.

};

// Helper function to get week number
function getWeekNumber(d) {
Copy link
Collaborator

@jlwllmr jlwllmr Feb 18, 2025

Choose a reason for hiding this comment

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

We need to retain line 31 in this function otherwise there's a risk that week numbering will be wrong. The ISO system uses Thursday as an anchor day (hence the +4, where 0 is Monday, the week start) to ensure that the week 1 is actually the first week of the year that has at least 4 days in the calendar year. See here.

@jlwllmr jlwllmr requested a review from sammysango February 18, 2025 14:42
@sammysango
Copy link
Collaborator

@sergeypanin1994 Card script improvements looking great! One question, for this point:

Fixed splitTitleIntoLines logic to prevent text loss

As far as I can tell, this removes the logic that handles long titles by truncating them with .... With this change, the title will end part-way through if it hits the max, but without a ... indication that the text has been cut short. So either way, text loss occurs, but the previous method deals with this more elegantly imo. Please correct me if I'm wrong/missing something though!

I don't think this actually affects any of the docs/cards at their current title length, but it'd be preferable to retain as a safeguard against future lengthy titles, if they occur.

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.

3 participants