forked from YeungKC/Hakuba
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
181 additions
and
102 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
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,39 @@ | ||
export interface FetchViewerType { | ||
viewer: { | ||
login: string; | ||
url: string; | ||
bio: string; | ||
}; | ||
} | ||
|
||
export interface DiscussionsType { | ||
number: number; | ||
title: string; | ||
createdAt: string; | ||
publishedAt: string; | ||
lastEditedAt?: string; | ||
url: string; | ||
body: string; | ||
category: { | ||
name: string; | ||
}; | ||
labels: { | ||
nodes: { | ||
name: string; | ||
color: string; | ||
}[]; | ||
}; | ||
} | ||
|
||
export interface PageInfo { | ||
hasNextPage: boolean; | ||
endCursor?: string; | ||
} | ||
export interface FetchDiscussionsType { | ||
repository: { | ||
discussions: { | ||
pageInfo: PageInfo; | ||
nodes: DiscussionsType[]; | ||
}; | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
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,48 @@ | ||
import path from 'path'; | ||
import { mkdirSync, promises } from 'fs'; | ||
import { DiscussionsType } from './types'; | ||
import Post from '../src/lib/types/post'; | ||
|
||
export const writePosts = async (list: DiscussionsType[]) => { | ||
const dir = path.join('./src/routes/posts/_source'); | ||
mkdirSync(dir, { recursive: true }); | ||
await Promise.all( | ||
list.map(({ number, body }) => { | ||
const p = path.resolve(dir, `${number}.md`); | ||
return promises.writeFile(p, body); | ||
}) | ||
); | ||
}; | ||
|
||
export const writePages = async (list: DiscussionsType[]) => { | ||
const dir = path.join('./src/routes'); | ||
mkdirSync(dir, { recursive: true }); | ||
await Promise.all( | ||
list.map(({ title, body }) => { | ||
const p = path.resolve(dir, `${title.toLowerCase()}.md`); | ||
return promises.writeFile(p, body); | ||
}) | ||
); | ||
}; | ||
|
||
export const writeEnv = async ( | ||
config: Record<string, string>, | ||
pages: DiscussionsType[], | ||
posts: DiscussionsType[] | ||
) => { | ||
config.PAGES = JSON.stringify(pages.map(({ title }) => title)); | ||
config.POSTS = JSON.stringify( | ||
posts.map<Post>((node) => ({ | ||
title: node.title, | ||
published: node.publishedAt, | ||
updated: node.lastEditedAt, | ||
number: node.number, | ||
url: node.url, | ||
labels: node.labels.nodes | ||
})) | ||
); | ||
const content = Object.entries(config) | ||
.map(([key, value]) => `VITE_${key}=${value}`) | ||
.join('\n'); | ||
return promises.writeFile('./.env.local', content); | ||
}; |
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
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,2 @@ | ||
'use strict'; | ||
exports.__esModule = true; |
Oops, something went wrong.