tylersong 1.0.15 โ 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/lib/sanity.d.ts +1 -1
- package/dist/lib/sanity.js +22 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,23 @@
|
|
|
46
46
|
npx tylersong
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
### ๐ง ํ๊ฒฝ ๋ณ์ ์ค์ (์ ํ์ฌํญ)
|
|
50
|
+
|
|
51
|
+
๋ ์์ธํ ๊ฒฝ๋ ฅ ์ ๋ณด์ ํฌํธํด๋ฆฌ์ค ์ ๋ณด๋ฅผ ๋ณด๋ ค๋ฉด Sanity CMS ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ ํ์ธ์:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# ํ๊ฒฝ ๋ณ์ ์ค์
|
|
55
|
+
export SANITY_PROJECT_ID='your-project-id'
|
|
56
|
+
export SANITY_DATASET='production'
|
|
57
|
+
export SANITY_API_VERSION='2025-12-06'
|
|
58
|
+
export SANITY_API_TOKEN='your-token' # ์ ํ์ฌํญ, ์ฝ๊ธฐ ์ ์ฉ ๊ถ์ฅ
|
|
59
|
+
|
|
60
|
+
# ์คํ
|
|
61
|
+
npx tylersong
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
> **์ฐธ๊ณ **: ํ๊ฒฝ ๋ณ์๊ฐ ์ค์ ๋์ง ์์๋ ๊ธฐ๋ณธ ํ๋กํ ์ ๋ณด๋ ์ ์์ ์ผ๋ก ํ์๋ฉ๋๋ค.
|
|
65
|
+
|
|
49
66
|
### ๐ฆ ์ ์ญ ์ค์น
|
|
50
67
|
|
|
51
68
|
์์ฃผ ์ฌ์ฉํ๋ค๋ฉด ์ ์ญ์ผ๋ก ์ค์นํ์ธ์:
|
package/dist/lib/sanity.d.ts
CHANGED
|
@@ -22,5 +22,5 @@ export declare const getPortfolio: (name: string | undefined) => Promise<Portfol
|
|
|
22
22
|
/**
|
|
23
23
|
* Sanity ํด๋ผ์ด์ธํธ ์ธ์คํด์ค๋ฅผ ๋ฐํํฉ๋๋ค (ํ์ํ ๊ฒฝ์ฐ)
|
|
24
24
|
*/
|
|
25
|
-
export declare const getSanityClient: () => ReturnType<typeof createClient
|
|
25
|
+
export declare const getSanityClient: () => ReturnType<typeof createClient> | null;
|
|
26
26
|
//# sourceMappingURL=sanity.d.ts.map
|
package/dist/lib/sanity.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createClient } from "@sanity/client";
|
|
|
2
2
|
/**
|
|
3
3
|
* ํ๊ฒฝ ๋ณ์์์ Sanity ์ค์ ์ ๋ก๋ํฉ๋๋ค
|
|
4
4
|
* npm ํจํค์ง์์๋ process.env์์๋ง ์ฝ์ต๋๋ค
|
|
5
|
+
* ํ๊ฒฝ ๋ณ์๊ฐ ์์ผ๋ฉด null์ ๋ฐํํฉ๋๋ค
|
|
5
6
|
*/
|
|
6
7
|
const loadEnvConfig = () => {
|
|
7
8
|
const projectId = process.env.SANITY_PROJECT_ID;
|
|
@@ -9,15 +10,7 @@ const loadEnvConfig = () => {
|
|
|
9
10
|
const apiVersion = process.env.SANITY_API_VERSION;
|
|
10
11
|
const token = process.env.SANITY_API_TOKEN;
|
|
11
12
|
if (!projectId || !dataset || !apiVersion) {
|
|
12
|
-
|
|
13
|
-
" - SANITY_PROJECT_ID\n" +
|
|
14
|
-
" - SANITY_DATASET\n" +
|
|
15
|
-
" - SANITY_API_VERSION\n" +
|
|
16
|
-
" - SANITY_API_TOKEN (์ ํ์ฌํญ)\n\n" +
|
|
17
|
-
"ํ๊ฒฝ ๋ณ์ ์ค์ ๋ฐฉ๋ฒ:\n" +
|
|
18
|
-
" export SANITY_PROJECT_ID='your-project-id'\n" +
|
|
19
|
-
" export SANITY_DATASET='production'\n" +
|
|
20
|
-
" export SANITY_API_VERSION='2025-12-06'");
|
|
13
|
+
return null;
|
|
21
14
|
}
|
|
22
15
|
return {
|
|
23
16
|
projectId,
|
|
@@ -32,6 +25,9 @@ const loadEnvConfig = () => {
|
|
|
32
25
|
*/
|
|
33
26
|
const createSanityClient = () => {
|
|
34
27
|
const config = loadEnvConfig();
|
|
28
|
+
if (!config) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
35
31
|
return createClient({
|
|
36
32
|
projectId: config.projectId,
|
|
37
33
|
dataset: config.dataset,
|
|
@@ -46,7 +42,7 @@ let client = null;
|
|
|
46
42
|
* Sanity ํด๋ผ์ด์ธํธ๋ฅผ ๊ฐ์ ธ์ต๋๋ค (์ง์ฐ ์ด๊ธฐํ)
|
|
47
43
|
*/
|
|
48
44
|
const getClient = () => {
|
|
49
|
-
if (
|
|
45
|
+
if (client === null) {
|
|
50
46
|
client = createSanityClient();
|
|
51
47
|
}
|
|
52
48
|
return client;
|
|
@@ -56,6 +52,10 @@ const getClient = () => {
|
|
|
56
52
|
*/
|
|
57
53
|
export const getExperiences = async () => {
|
|
58
54
|
try {
|
|
55
|
+
const client = getClient();
|
|
56
|
+
if (!client) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
59
|
const query = `*[_type == "experience"] | order(startDate asc) {
|
|
60
60
|
_id,
|
|
61
61
|
company,
|
|
@@ -66,7 +66,7 @@ export const getExperiences = async () => {
|
|
|
66
66
|
technologies,
|
|
67
67
|
location
|
|
68
68
|
}`;
|
|
69
|
-
const experiences = await
|
|
69
|
+
const experiences = await client.fetch(query);
|
|
70
70
|
return experiences;
|
|
71
71
|
}
|
|
72
72
|
catch (error) {
|
|
@@ -78,6 +78,10 @@ export const getExperiences = async () => {
|
|
|
78
78
|
*/
|
|
79
79
|
export const getExperienceById = async (id) => {
|
|
80
80
|
try {
|
|
81
|
+
const client = getClient();
|
|
82
|
+
if (!client) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
81
85
|
const query = `*[_type == "experience" && _id == $id][0] {
|
|
82
86
|
_id,
|
|
83
87
|
company,
|
|
@@ -88,7 +92,7 @@ export const getExperienceById = async (id) => {
|
|
|
88
92
|
technologies,
|
|
89
93
|
location
|
|
90
94
|
}`;
|
|
91
|
-
const experience = await
|
|
95
|
+
const experience = await client.fetch(query, {
|
|
92
96
|
id,
|
|
93
97
|
});
|
|
94
98
|
return experience;
|
|
@@ -99,6 +103,10 @@ export const getExperienceById = async (id) => {
|
|
|
99
103
|
};
|
|
100
104
|
export const getPortfolio = async (name) => {
|
|
101
105
|
try {
|
|
106
|
+
const client = getClient();
|
|
107
|
+
if (!client) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
102
110
|
// name์ด ์ ๊ณต๋ ๊ฒฝ์ฐ author์ name๊ณผ ์ผ์นํ๋ portfolio๋ง ์กฐํ
|
|
103
111
|
const query = `*[_type == "portfolio" && author->name == $name][0] {
|
|
104
112
|
"author": author-> {
|
|
@@ -107,8 +115,8 @@ export const getPortfolio = async (name) => {
|
|
|
107
115
|
}
|
|
108
116
|
}`;
|
|
109
117
|
const portfolio = name
|
|
110
|
-
? await
|
|
111
|
-
: await
|
|
118
|
+
? await client.fetch(query, { name })
|
|
119
|
+
: await client.fetch(query);
|
|
112
120
|
return portfolio;
|
|
113
121
|
}
|
|
114
122
|
catch (error) {
|