Skip to content

Commit c3d012d

Browse files
committed
backup
1 parent 345996d commit c3d012d

3 files changed

Lines changed: 79 additions & 4 deletions

File tree

build.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "-- 빌드 시작 --"
6+
7+
echo "1. public 디렉토리 초기화"
8+
mkdir -p public
9+
find public/ -mindepth 1 -delete
10+
11+
echo "2. sass 컴파일"
12+
pnpm sass layout/styles:public/styles --style=compressed
13+
14+
echo "3. esbuild 컴파일"
15+
pnpm esbuild layout/js/main.ts --bundle --outfile=public/js/main.js --minify --target=es2017
16+
17+
echo "4. .nojekyll 파일 생성"
18+
touch public/.nojekyll
19+
20+
echo "5. robots.txt 파일 복사"
21+
cp layout/robots.txt public/robots.txt
22+
23+
echo "6. assets 디렉토리 복사"
24+
cp -r assets/ public/assets
25+
26+
if [ "$1" = "production" ]; then
27+
echo "7. 프로덕션 모드로 go 실행"
28+
pnpm cross-env APP_ENV=production go run .
29+
else
30+
echo "7. 개발 모드로 go 실행"
31+
go run .
32+
fi
33+
34+
echo "-- 빌드 완료 --"

main.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,49 @@ import (
3636

3737
// TODO: category 내부 fixed에서는 다중 fixed가 적용되었다면, 파일명으로 정렬됨.
3838

39+
// Refactor TODO:
40+
/*
41+
0. CI/CD
42+
1. pnpm run build 하면 build.sh 먼저 실행 및 go run .
43+
2. pnpm run build:prod 하면 build.sh 먼저 실행 및 cross-env APP_ENV=production go run .
44+
45+
1. data 처리:
46+
1. build.sh:
47+
1. unix 명령어로 public 디렉토리 초기화(없으면 생성, 있으면 초기화)
48+
DOCS: public 디렉토리 자체는 이제 main.go에서 처리하지 않음(즉, 생성 및 초기화 안함)
49+
2. sass 명령어로 public/styles 디렉토리 생성 및 scss 컴파일
50+
3. esbuild 명령어로 public/js 디렉토리 생성 및 js 컴파일
51+
4. unix 명령어로 .nojekyll 파일 생성
52+
5. unix 명령어로 robots.txt 파일 복사해서 붙여넣기
53+
6. content/assets 속 모든 파일 public/assets에 붙여넣기
54+
2. main.go:
55+
1. 포스트 관련 처리
56+
1. PostsData 처리
57+
- title string
58+
- date string
59+
- description string
60+
- category []string
61+
- fixedPost bool
62+
- fixedCategory bool
63+
- contentPath string <- 실제 블로그가 저장된 위치
64+
e.g. content/tgpl/go 정리법
65+
- URL <- 실제 URL로 참조되는 블로그 URL <- env: production 이면 .html 안함, 그게 아니면 .html 추가
66+
e.g. post/go-정리법
67+
e.g. post/go-정리법.html
68+
2. post.html 생성
69+
href: posts/category-foo, /, about, posts
70+
DOCS: href는 해당 html에 포함된 hyperlink임
71+
3. posts.html 생성
72+
href: posts/category-foo, /, about, posts
73+
4. posts/category-foo.html 생성
74+
href: /, about, posts
75+
2. 블로그 관련 처리
76+
1. index.html 생성
77+
2. about.html 생성
78+
2.
79+
80+
*/
81+
3982
func main() {
4083
var appEnv string = os.Getenv("APP_ENV")
4184

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
"version": "1.0.0",
44
"description": "",
55
"scripts": {
6-
"build": "go run . && pnpm run build:css && pnpm run build:js",
7-
"build:css": "sass layout/styles:public/styles --style=compressed",
8-
"build:js": "esbuild layout/js/main.ts --bundle --outfile=public/js/main.js --minify --target=es2017",
9-
"build:prod": "cross-env APP_ENV=production go run . && pnpm run build:css && pnpm run build:js",
6+
"build": "bash ./build.sh",
7+
"build:prod": "bash ./build.sh production",
108
"serve": "devd -ol public/",
119
"watch": "chokidar \"layout/**/*\" \"content/**/*\" -c \"pnpm run build\" --initial --debounce=1000",
1210
"dev": "concurrently \"pnpm run watch\" \"pnpm run serve\""

0 commit comments

Comments
 (0)