@unana_dev/doxen 0.3.0 → 0.3.2

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 CHANGED
@@ -585,4 +585,8 @@ npx wrangler d1 execute 데이터베이스이름 --remote --file=node_modules/@u
585
585
 
586
586
  저장소의 Actions variables에 배포된 문서 사이트 주소를 `DOXEN_SITE_URL`로 등록하세요. 설정 파일이 저장소 루트의 기본 이름이 아니라면 `DOXEN_CONFIG`에 저장소 기준 경로도 등록합니다. 보고서의 각 댓글에는 보고서 실행 시점 커밋의 GitHub 원본 파일 링크와 배포 사이트의 해당 댓글 링크가 표시됩니다. 현재 설정에서 문서를 찾지 못하면 링크 대신 안내 문구가 표시됩니다.
587
587
 
588
- 매일 한국 시간 오전 8시에 전날 00:00~24:00의 댓글을 하나의 이슈로 작성합니다. 댓글은 문서별로 묶이며, 같은 문서 안에서는 작성 순서대로 표시됩니다. 댓글이 없으면 이슈를 만들지 않으며, 같은 날짜의 보고서 이슈가 이미 있으면 중복 생성하지 않습니다. Actions 화면의 수동 실행에서 날짜를 입력해 누락된 날을 다시 집계할 수 있습니다. 이슈 본문 양식은 패키지의 `src/comment-report.js`에서 확인할 수 있으며 필요에 맞게 복사해 수정하세요. 댓글 내용과 작성자 이메일이 이슈 저장소의 열람자에게 공개되므로 접근 권한을 확인하세요. GitHub 예약 실행은 지연되거나 누락될 수 있습니다.
588
+ 매일 한국 시간 00시에 전날 00:00~24:00의 댓글을 하나의 이슈로 작성합니다. 실행 시각은 복사한 `.github/workflows/comment-report.yml`의 `schedule`에서 설정합니다. 예를 들어 한국 시간 오전 8시에 실행하려면 `cron: '0 8 * * *'`로 바꾸세요. `timezone: 'Asia/Seoul'`을 유지하면 한국 시간으로 적용됩니다. 설정한 시각에 하루 한 번 실행되며, 기존 워크플로를 사용 중이라면 변경된 템플릿의 `schedule`을 반영해야 합니다.
589
+
590
+ 댓글은 문서별로 묶이며, 같은 문서 안에서는 작성 순서대로 표시됩니다. 댓글이 없으면 이슈를 만들지 않으며, 같은 날짜의 보고서 이슈가 이미 있으면 중복 생성하지 않습니다. Actions 화면의 수동 실행에서 날짜를 입력해 누락된 날을 다시 집계할 수 있습니다. 이슈 본문 양식은 패키지의 `src/comment-report.js`에서 확인할 수 있으며 필요에 맞게 복사해 수정하세요. 댓글 내용과 작성자 이메일이 이슈 저장소의 열람자에게 공개되므로 접근 권한을 확인하세요. GitHub 예약 실행은 지연되거나 누락될 수 있습니다.
591
+
592
+ 문서별 최종 수정자와 수정일을 표시하려면 빌드 환경에 전체 Git 이력이 필요합니다. GitHub Actions에서는 `actions/checkout`에 `fetch-depth: 0`을 설정하세요. 얕은 복제의 경계 커밋은 파일의 실제 마지막 수정인지 확인할 수 없어 해당 정보가 표시되지 않습니다.
package/client/app.js CHANGED
@@ -662,6 +662,19 @@ function render() {
662
662
  $("#article").innerHTML = current.html;
663
663
  if (!$("#article h1")) $("#article").prepend(el("h1", current.title));
664
664
  renderModified(current);
665
+ if (current.markdown) {
666
+ const heading = $("#article h1");
667
+ const title = el("div", undefined, "document-title");
668
+ heading.before(title);
669
+ title.append(heading);
670
+ const download = el("a", undefined, "document-download");
671
+ download.href = current.markdown;
672
+ download.download = current.path.split("/").at(-1);
673
+ download.setAttribute("aria-label", "Markdown 파일 다운로드");
674
+ download.title = "Markdown 파일 다운로드";
675
+ download.innerHTML = '<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3v12m-4-4 4 4 4-4M4 17v3h16v-3"/></svg>';
676
+ title.append(download);
677
+ }
665
678
  for (const heading of $("#article").querySelectorAll("h2, h3, h4, h5, h6")) {
666
679
  if (/^version\s*:\s*\S+/i.test(heading.textContent.trim()))
667
680
  heading.classList.add("document-version");
@@ -16,10 +16,14 @@ export async function attachComments(article, documentId, commentId) {
16
16
  if (article.dataset.commentDocument !== documentId) return;
17
17
  document.body.classList.add('has-comments');
18
18
  const blocks = [...article.querySelectorAll('h1, h2, h3, h4, h5, h6, p, li, pre, blockquote, td, th')]
19
- .filter((node) => !node.querySelector('p, li, pre, blockquote, td, th') && node.textContent.trim());
19
+ .filter((node) => {
20
+ if (node.tagName === 'LI') return [...node.childNodes].some((child) => !(child.nodeType === 1 && child.matches('ul, ol, p, pre, blockquote')) && child.textContent.trim());
21
+ return !node.querySelector('p, li, pre, blockquote, td, th') && node.textContent.trim();
22
+ });
20
23
  const occurrences = new Map();
21
24
  const matched = new Set();
22
25
  const anchors = new Map();
26
+ const anchorBlocks = new Map();
23
27
  const popover = document.createElement('button');
24
28
  popover.type = 'button';
25
29
  popover.className = 'comment-selection-trigger';
@@ -94,7 +98,8 @@ export async function attachComments(article, documentId, commentId) {
94
98
  popover.hidden = true;
95
99
  });
96
100
  for (const block of blocks) {
97
- const text = block.textContent.trim();
101
+ const ownNodes = block.tagName === 'LI' ? [...block.childNodes].filter((child) => !(child.nodeType === 1 && child.matches('ul, ol, p, pre, blockquote'))) : null;
102
+ const text = ownNodes ? ownNodes.map((node) => node.textContent).join('').trim() : block.textContent.trim();
98
103
  const occurrence = occurrences.get(text) || 0;
99
104
  occurrences.set(text, occurrence + 1);
100
105
  const key = JSON.stringify([text, occurrence]);
@@ -102,9 +107,15 @@ export async function attachComments(article, documentId, commentId) {
102
107
  matched.add(key);
103
108
  const wrapper = document.createElement('div');
104
109
  wrapper.className = 'comment-anchor';
110
+ anchorBlocks.set(wrapper, block);
105
111
  if (['LI', 'TD', 'TH'].includes(block.tagName)) {
106
- wrapper.append(...block.childNodes);
107
- block.append(wrapper);
112
+ if (ownNodes) {
113
+ block.insertBefore(wrapper, ownNodes[0]);
114
+ wrapper.append(...ownNodes);
115
+ } else {
116
+ wrapper.append(...block.childNodes);
117
+ block.append(wrapper);
118
+ }
108
119
  } else {
109
120
  block.before(wrapper);
110
121
  wrapper.append(block);
@@ -289,6 +300,13 @@ export async function attachComments(article, documentId, commentId) {
289
300
  for (const other of article.querySelectorAll('.comment-anchor > .comment-panel')) other.hidden = true;
290
301
  for (const other of article.querySelectorAll('.comment-trigger.is-open')) other.classList.remove('is-open');
291
302
  draftQuote = quote;
303
+ if (!range) {
304
+ range = document.createRange();
305
+ if (['LI', 'TD', 'TH'].includes(block.tagName)) {
306
+ range.setStart(wrapper, 0);
307
+ range.setEndBefore(button);
308
+ } else range.selectNodeContents(block);
309
+ }
292
310
  showDraftHighlight(block, range);
293
311
  panel.hidden = false;
294
312
  button.classList.add('is-open');
@@ -314,6 +332,15 @@ export async function attachComments(article, documentId, commentId) {
314
332
  const alignButtons = () => {
315
333
  const right = article.getBoundingClientRect().right;
316
334
  for (const wrapper of anchors.keys()) {
335
+ const range = document.createRange();
336
+ const block = anchorBlocks.get(wrapper);
337
+ if (['LI', 'TD', 'TH'].includes(block.tagName)) {
338
+ range.setStart(wrapper, 0);
339
+ range.setEndBefore(wrapper.querySelector('.comment-trigger'));
340
+ } else range.selectNodeContents(block);
341
+ const content = range.getBoundingClientRect();
342
+ const bounds = wrapper.getBoundingClientRect();
343
+ wrapper.style.setProperty('--comment-center', `${(content.top + content.bottom) / 2 - bounds.top}px`);
317
344
  wrapper.style.setProperty('--comment-offset', `${Math.max(0, right - wrapper.getBoundingClientRect().right)}px`);
318
345
  wrapper.style.setProperty('--comment-panel-right', `${wrapper.getBoundingClientRect().right - window.innerWidth + 16}px`);
319
346
  }
package/client/style.css CHANGED
@@ -1152,7 +1152,7 @@ dialog::backdrop {
1152
1152
  }
1153
1153
 
1154
1154
  .comment-anchor { position: relative; }
1155
- .comment-trigger { position: absolute; left: calc(100% + 20px); top: 0; z-index: 2; display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px 0 3px; border: 0; border-radius: 14px; background: transparent; color: #374151; font-size: 13px; font-weight: 600; cursor: pointer; opacity: 0; white-space: nowrap; }
1155
+ .comment-trigger { position: absolute; left: calc(100% + 20px); top: var(--comment-center, 0px); transform: translateY(-50%); z-index: 2; display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px 0 3px; border: 0; border-radius: 14px; background: transparent; color: #374151; font-size: 13px; font-weight: 600; cursor: pointer; opacity: 0; white-space: nowrap; }
1156
1156
  .comment-trigger:not(:has(.comment-avatar)) { width: 32px; height: 32px; padding: 0; justify-content: center; color: #9ca3af; }
1157
1157
  .comment-anchor:hover > .comment-trigger, .comment-trigger:focus-visible, .comment-trigger:has(.comment-avatar) { opacity: 1; }
1158
1158
  .comment-trigger:hover:has(.comment-avatar), .comment-trigger:focus-visible:has(.comment-avatar) { background: #f3f4f6; }
@@ -1290,3 +1290,9 @@ body.has-comments .comment-panel { left: auto; right: var(--comment-panel-right)
1290
1290
  .search-trigger { width: 150px; }
1291
1291
  #search-dialog { top: 80px; max-height: calc(100vh - 100px); }
1292
1292
  }
1293
+
1294
+ .document-title { display: flex; align-items: flex-start; gap: 12px; }
1295
+ .document-title h1 { flex: 1; min-width: 0; }
1296
+ .document-download { display: grid; flex: none; place-items: center; width: 36px; height: 36px; border-radius: 6px; color: #6b7280; }
1297
+ .document-download:hover { background: #f3f4f6; color: #191919; }
1298
+ .document-title > .comment-anchor { flex: 1; min-width: 0; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unana_dev/doxen",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Config-first Markdown documentation sites with Korean and section search",
5
5
  "type": "module",
6
6
  "bin": {
package/src/content.js CHANGED
@@ -14,9 +14,14 @@ const execFileAsync = promisify(execFile);
14
14
 
15
15
  async function modificationInfo(file, root) {
16
16
  try {
17
- const { stdout } = await execFileAsync("git", ["log", "-1", "--format=%aI%n%an", "--follow", "--", file], { cwd: root });
18
- const [date, author] = stdout.trim().split("\n");
19
- if (date) return { date, author };
17
+ const { stdout } = await execFileAsync("git", ["log", "-1", "--format=%H%n%aI%n%an", "--follow", "--", file], { cwd: root });
18
+ const [commit, date, author] = stdout.trim().split("\n");
19
+ if (date) {
20
+ const { stdout: shallowPath } = await execFileAsync("git", ["rev-parse", "--git-path", "shallow"], { cwd: root });
21
+ const boundaries = await readFile(path.resolve(root, shallowPath.trim()), "utf8").catch(() => "");
22
+ if (!boundaries.split(/\s+/).includes(commit)) return { date, author };
23
+ return {};
24
+ }
20
25
  } catch {
21
26
  // Files outside Git or environments without Git use the filesystem timestamp.
22
27
  }
@@ -100,6 +105,9 @@ export async function collectSite(config) {
100
105
  delete doc.file;
101
106
  continue;
102
107
  }
108
+ const hash = createHash("sha256").update(doc.source).digest("hex").slice(0, 20);
109
+ assets.set(`${hash}.md`, Buffer.from(doc.source));
110
+ doc.markdown = `./assets/${hash}.md`;
103
111
  const slugger = new GithubSlugger();
104
112
  const md = new MarkdownIt({
105
113
  html: false,
@@ -1,7 +1,8 @@
1
1
  name: Daily Doxen comments
2
2
  on:
3
3
  schedule:
4
- - cron: '0 23 * * *' # 매일 오전 8시 (Asia/Seoul)
4
+ - cron: '0 0 * * *' # 매일 한국 시간 00:00
5
+ timezone: 'Asia/Seoul'
5
6
  workflow_dispatch:
6
7
  inputs:
7
8
  report_date: