Skip to content

Commit

Permalink
Refactor post sorting, update blog post link (#295)
Browse files Browse the repository at this point in the history
* Comment out `console.log` in `chat.js`

* Update path to new blog post name

* Update sorting logic in getSortedPosts.ts

Use `valueOf()` instead of `Date.parse` and `toString()` to compare dates in `getSortedPosts.ts` because the `pubDate` will always be a `Date` object. Converting to string and parsing that string for a date is unnecessary.
  • Loading branch information
AVGVSTVS96 authored Apr 29, 2024
1 parent 578b215 commit b11f47f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/gptChat/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (modelName === 'gpt3') {
} else if (modelName === 'gpt4') {
modelName = 'gpt-4';
}
console.log(modelName);
// console.log(modelName);

let autoScrollState = true;
let lastScrollTop = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/about.astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Card from '@components/Card.astro';
<p slot="content">
For more information on Astro and how I used it to build this website,
visit <a
href="/posts/blog1"
href="posts/buildingthissitewithastro"
class="font-semibold hover:text-muted-light/85"
>How I built this website</a
>.
Expand Down
4 changes: 1 addition & 3 deletions src/utils/getSortedPosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ import type { CollectionEntry } from 'astro:content';
type posts = CollectionEntry<'posts'>;

export const sortedBlogPosts: posts[] = (await getCollection('posts')).sort(
(a, b) =>
Date.parse(b.data.pubDate.toString()) -
Date.parse(a.data.pubDate.toString())
(a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()
);

0 comments on commit b11f47f

Please sign in to comment.