-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add blog interface #11
- Loading branch information
Showing
6 changed files
with
105 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
# title: The Code Hive Blog | ||
subtext: Updates from the Hive | ||
index: true | ||
# sidebar: true | ||
--- | ||
|
||
# The Code Hive Blog | ||
|
||
Periodic musings from the ’hive. | ||
|
||
_Latest Posts:_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: 2023 in review | ||
date: 2023-12-31 | ||
--- | ||
|
||
This is a post. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// from https://github.com/vuejs/blog | ||
import { createContentLoader } from 'vitepress' | ||
import formatDate from './formatDate'; | ||
|
||
interface Post { | ||
title: string | ||
url: string, | ||
excerpt?: string, | ||
date: string[], | ||
}; | ||
|
||
declare const data: Post[]; | ||
|
||
export { data }; | ||
|
||
export default createContentLoader('en/posts/*.md', { | ||
excerpt: true, | ||
transform(raw): Post[] { | ||
return raw | ||
.map(({ url, frontmatter, excerpt }) => ({ | ||
title: frontmatter.title, | ||
url, | ||
excerpt, | ||
date: formatDate(frontmatter.date) | ||
})) | ||
.sort((a, b) => a.date[0].localeCompare(b.date[0], [])); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
const fmt = new Intl.DateTimeFormat(['en-US'], {day: 'numeric', month: 'short', year: 'numeric'}); | ||
|
||
/** iso, fmt */ | ||
export default function formatDate(raw: string): string[] { | ||
const d = new Date(raw); | ||
d.setUTCHours(12); // keep away from boundaries | ||
return [d.toISOString(), fmt.format(d)]; | ||
} |