Skip to content

Commit 976550e

Browse files
benelogclaude
andcommitted
GitHub Edit 버튼 추가 및 설정 파일을 YAML로 전환
- site.json을 site.yaml로 전환하고 yaml 파서 도입 - gitHub.repository-url, gitHub.content-branch 설정 추가 - 상세 페이지 제목 옆에 GitHub 편집 링크 Edit 버튼 렌더링 - repository-url 미설정 시 Edit 버튼 미표시, content-branch 기본값 main Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c95eab8 commit 976550e

10 files changed

Lines changed: 102 additions & 34 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Obsidian vault 기반 개발 노트 모음. `obsidian-site-action/`의 빌드
77
## 핵심 구조
88

99
- `content/*.md` — 270개 마크다운 노트 (플랫 구조)
10-
- `site.json` — 사이트 설정 (title, subtitle, lang, output)
10+
- `site.yaml` — 사이트 설정 (title, subtitle, lang, output-directory)
1111
- `obsidian-site-action/` — 빌드 도구 (추후 별도 repo로 분리 예정)
1212
- `build.ts` — 진입점. `import.meta.url` 기준으로 layouts/styles를 찾고, vault 경로는 `--source`로 받음
1313
- `layouts/page.html`, `layouts/index.html` — HTML 템플릿. `{title}`, `{body}` 등 플레이스홀더 사용

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,20 @@ npm run build -- --output dist # 출력 디렉토리 변경
3535

3636
### 설정
3737

38-
`site.json`으로 사이트 메타데이터를 설정한다.
39-
40-
```json
41-
{
42-
"title": "devnote",
43-
"subtitle": "정상혁의 개발수첩",
44-
"lang": "ko",
45-
"output": "public"
46-
}
38+
`site.yaml`로 사이트 메타데이터를 설정한다.
39+
40+
```yaml
41+
title: devnote
42+
subtitle: 정상혁의 개발수첩
43+
lang: ko
44+
output-directory: public
4745
```
4846
4947
## 구조
5048
5149
```
5250
content/*.md # Obsidian 노트 (플랫 구조)
53-
site.json # 사이트 설정
51+
site.yaml # 사이트 설정
5452
obsidian-site-action/ # 빌드 도구
5553
build.ts # 빌드 스크립트 (진입점)
5654
render.ts # HTML 렌더링

obsidian-site-action/build.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { readFileSync, writeFileSync, mkdirSync, readdirSync, copyFileSync, existsSync } from 'fs';
77
import { resolve, join, basename, extname } from 'path';
88
import { fileURLToPath } from 'url';
9+
import { parse as parseYaml } from 'yaml';
910

1011
import { buildGraph, buildBacklinks } from './graph.js';
1112
import { buildPage, buildIndex } from './render.js';
@@ -19,18 +20,24 @@ export interface PageInfo {
1920
content: string;
2021
}
2122

23+
export interface GitHubConfig {
24+
'repository-url': string;
25+
'content-branch'?: string;
26+
}
27+
2228
export interface SiteConfig {
2329
title: string;
2430
subtitle: string;
2531
lang: string;
26-
output: string;
32+
'output-directory': string;
33+
gitHub?: GitHubConfig;
2734
}
2835

2936
function loadConfig(source: string): SiteConfig {
30-
const config: SiteConfig = { title: basename(source), subtitle: '', lang: 'en', output: 'public' };
31-
const configPath = join(source, 'site.json');
37+
const config: SiteConfig = { title: basename(source), subtitle: '', lang: 'en', 'output-directory': 'public' };
38+
const configPath = join(source, 'site.yaml');
3239
if (existsSync(configPath)) {
33-
const data = JSON.parse(readFileSync(configPath, 'utf-8'));
40+
const data = parseYaml(readFileSync(configPath, 'utf-8'));
3441
Object.assign(config, data);
3542
}
3643
return config;
@@ -74,9 +81,9 @@ function main(): void {
7481
const source = args.source;
7582
const config = loadConfig(source);
7683
if (args.output) {
77-
config.output = args.output;
84+
config['output-directory'] = args.output;
7885
}
79-
const output = resolve(source, config.output);
86+
const output = resolve(source, config['output-directory']);
8087

8188
console.log(`Source: ${source}`);
8289
console.log(`Output: ${output}`);

obsidian-site-action/layouts/page.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515

1616
<div class="page-layout">
1717
<main class="content">
18-
<h1>{title}</h1>
18+
<div class="content-header">
19+
<h1>{title}</h1>
20+
{edit_link}
21+
</div>
1922
{body}
2023
</main>
2124

obsidian-site-action/package-lock.json

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

obsidian-site-action/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"test": "vitest run"
99
},
1010
"dependencies": {
11-
"marked": "^15.0.0"
11+
"marked": "^15.0.0",
12+
"yaml": "^2.8.2"
1213
},
1314
"devDependencies": {
1415
"@types/node": "^20.0.0",

obsidian-site-action/render.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { marked } from 'marked';
6-
import { WIKILINK_RE, type PageInfo, type SiteConfig } from './build.js';
6+
import { WIKILINK_RE, type PageInfo, type SiteConfig, type GitHubConfig } from './build.js';
77
import { extractWikilinks } from './graph.js';
88
import type { GraphData } from './graph.js';
99

@@ -62,6 +62,13 @@ export function renderBacklinks(stem: string, backlinks: Map<string, string[]>,
6262
return '<section class="backlinks"><h2>Backlinks</h2><ul>' + items.join('\n') + '</ul></section>';
6363
}
6464

65+
export function renderEditLink(stem: string, gitHub?: GitHubConfig): string {
66+
if (!gitHub?.['repository-url']) return '';
67+
const branch = gitHub['content-branch'] || 'main';
68+
const url = `${gitHub['repository-url']}/edit/${branch}/content/${stem}.md`;
69+
return `<a href="${url}" class="edit-link" target="_blank" rel="noopener noreferrer">Edit</a>`;
70+
}
71+
6572
export function buildPage(
6673
stem: string,
6774
pages: Map<string, PageInfo>,
@@ -82,13 +89,16 @@ export function buildPage(
8289
const relatedHtml = renderRelated(wikilinks, pages);
8390
const backlinksHtml = renderBacklinks(stem, backlinks, pages);
8491

92+
const editLinkHtml = renderEditLink(stem, config.gitHub);
93+
8594
return template
8695
.replaceAll('{title}', title)
8796
.replaceAll('{site_title}', config.title)
8897
.replaceAll('{lang}', config.lang)
8998
.replaceAll('{body}', htmlBody)
9099
.replaceAll('{related}', relatedHtml)
91-
.replaceAll('{backlinks}', backlinksHtml);
100+
.replaceAll('{backlinks}', backlinksHtml)
101+
.replaceAll('{edit_link}', editLinkHtml);
92102
}
93103

94104
export function buildIndex(

obsidian-site-action/styles/style.css

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,17 @@ body {
100100
box-shadow: var(--shadow-card);
101101
}
102102

103-
.content h1 {
104-
font-size: 26px;
105-
font-weight: 800;
103+
.content-header {
104+
display: flex;
105+
align-items: flex-start;
106+
justify-content: space-between;
107+
gap: 16px;
106108
margin-bottom: 20px;
107109
padding-bottom: 16px;
108-
line-height: 1.3;
109-
letter-spacing: -0.5px;
110110
position: relative;
111111
}
112112

113-
.content h1::after {
113+
.content-header::after {
114114
content: '';
115115
position: absolute;
116116
bottom: 0;
@@ -121,6 +121,38 @@ body {
121121
border-radius: 2px;
122122
}
123123

124+
.content-header h1 {
125+
font-size: 26px;
126+
font-weight: 800;
127+
line-height: 1.3;
128+
letter-spacing: -0.5px;
129+
margin-bottom: 0;
130+
padding-bottom: 0;
131+
}
132+
133+
.content-header h1::after {
134+
display: none;
135+
}
136+
137+
.edit-link {
138+
flex-shrink: 0;
139+
font-size: 13px;
140+
font-weight: 700;
141+
color: var(--color-text-tertiary);
142+
text-decoration: none;
143+
border: 1px solid var(--color-border);
144+
border-radius: var(--radius-sm);
145+
padding: 4px 12px;
146+
transition: all 0.15s ease;
147+
margin-top: 4px;
148+
}
149+
150+
.edit-link:hover {
151+
color: var(--color-primary);
152+
border-color: var(--color-primary);
153+
text-decoration: none;
154+
}
155+
124156
.content h2 {
125157
font-size: 20px;
126158
font-weight: 700;

site.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

site.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
title: Devnote
2+
subtitle: Benelog의 개발수첩
3+
lang: ko
4+
output-directory: public
5+
gitHub:
6+
repository-url: https://github.com/benelog/devnote
7+
content-branch: main

0 commit comments

Comments
 (0)