This repository has been archived by the owner on Oct 3, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge torrust/torrust-website#115: add new date.ts module and argumen…
…t to getStars function d127462 Update date.ts (Graeme Byrne) d5ad4a5 add new date.ts module and argument to getStars function (grmbyrn) Pull request description: ## Enhancements to Date Formatting and `getStars` Function ### Changes Made: 1. **Date Formatting Module:** - Moved the `formatDate` function into a separate module located at `lib/utils/date.ts`. - Implemented in `lib/components/molecules/BlogPostCard.svelte`, `routes/(blog-article)/+layout.svelte` and `routes/rss.xml/+server.ts` - The motivation is to centralise the date and time formatting logic and provide a single source of truth for date formatting across all components. - By using this helper function, we can easily update the date format in one place, affecting all components simultaneously. - This approach facilitates testing of date formatting independently of specific components. ```typescript // src/lib/utils/date.ts import dateFormat from 'dateformat'; export function formatDate(date: string): string { return dateFormat(date, 'UTC:dd/mm/yyyy'); } export function formatTime(date: string): string { return dateFormat(date, 'UTC:HH:MM:ss'); } 2. `getStars` Function Modification: - Added an argument to the `getStars` function in the `ProjectCard` component (`lib/components/molecules/ProjectCard.svelte`). - The argument (`repoName`) replaces the previous usage of a global variable. - This change promotes better code organisation and maintainability by explicitly defining function inputs. - The modification improves the function's reusability and makes it more self-contained. ACKs for top commit: josecelano: ACK d127462 Tree-SHA512: 32883a9a97720a5375ad521b52e0e4cdf2bb79f310134d9435bf9ee9f3aab10287366cadcd3f6161dc5b6d4aa5e3a95dd7ce3c2ed1bde6de6706fd2b7fb478c0
- Loading branch information