Skip to content

Commit f67484c

Browse files
committed
feat(services): Posts services config to run in production mode
1 parent afedddf commit f67484c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/services/posts/posts.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@ interface Post {
44
content: string
55
}
66

7+
const GITHUB_RAW_HOST = 'https://raw.githubusercontent.com'
8+
const GITHUB_RAW_PATH = 'hfidelis/hfidelis.github.io/main/src/services/posts/files/'
9+
const GITHUB_RAW_URL = `${GITHUB_RAW_HOST}/${GITHUB_RAW_PATH}`
10+
711
const posts = import.meta.glob(
812
'@/services/posts/files/*.md',
913
{ import: 'default', eager: true },
1014
)
1115
const postPaths = Object.keys(posts)
1216

13-
const getPostContent = async (path: string): Promise<string> => {
17+
const getPostContent = async (path: string): Promise<string> => {
1418
const content = await import(path)
1519

16-
const rawContent = await fetch(content.default)
20+
const extractedPath = content.default.split('/').pop()
21+
22+
const rawContent = await fetch(GITHUB_RAW_URL + extractedPath)
1723

1824
return await rawContent.text()
1925
}

0 commit comments

Comments
 (0)