Skip to content

Commit 093d35f

Browse files
committed
hotfix: fix hackmd
1 parent ff902cd commit 093d35f

File tree

2 files changed

+32
-46
lines changed

2 files changed

+32
-46
lines changed

create-node-meeting-artifacts.mjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ import * as meetings from './src/meeting.mjs';
1818
// Step 1: Application configuration
1919
const config = getConfig();
2020

21-
// Step 2: Initialize HackMD client with meeting configuration
22-
const hackmdClient = hackmd.createHackMDClient(config);
23-
24-
// Step 3: Initialize Google Calendar client with API Key
21+
// Step 2: Initialize Google Calendar client with API Key
2522
const calendarClient = google.createCalendarClient(config.google);
2623

27-
// Step 4: Initialize GitHub client
24+
// Step 3: Initialize GitHub client
2825
const githubClient = github.createGitHubClient(config);
2926

30-
// Step 5: Read meeting configuration from templates
27+
// Step 4: Read meeting configuration from templates
3128
const meetingConfig = await meetings.readMeetingConfig(config);
3229

30+
// Step 5: Initialize HackMD client with meeting configuration
31+
const hackmdClient = hackmd.createHackMDClient(config, meetingConfig);
32+
3333
// Step 6: Find next meeting event in calendar
3434
const event = await google.findNextMeetingEvent(calendarClient, meetingConfig);
3535

@@ -57,14 +57,15 @@ const meetingAgenda = meetings.generateMeetingAgenda(gitHubAgendaIssues);
5757
const hackmdNote = await hackmd.createMeetingNotesDocument(
5858
hackmdClient,
5959
meetingTitle,
60-
'',
61-
meetingConfig
60+
''
6261
);
6362

6463
// Step 12: Get the HackMD document link
6564
const minutesDocLink =
6665
hackmdNote.publishLink || `https://hackmd.io/${hackmdNote.id}`;
6766

67+
console.log({ hackmdNote, minutesDocLink });
68+
6869
// Step 13: Generate meeting issue content using native implementation
6970
const issueContent = await meetings.generateMeetingIssue(
7071
config,
@@ -74,7 +75,7 @@ const issueContent = await meetings.generateMeetingIssue(
7475
minutesDocLink
7576
);
7677

77-
// // Step 14: Create GitHub issue with HackMD link
78+
// Step 14: Create GitHub issue with HackMD link
7879
const githubIssue = await github.createGitHubIssue(
7980
githubClient,
8081
meetingConfig,
@@ -96,8 +97,7 @@ const minutesContent = await meetings.generateMeetingMinutes(
9697
await hackmd.updateMeetingNotesDocument(
9798
hackmdClient,
9899
hackmdNote.id,
99-
minutesContent,
100-
meetingConfig
100+
minutesContent
101101
);
102102

103103
// Output success information with links

src/hackmd.mjs

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,51 @@ import { HACKMD_DEFAULT_PERMISSIONS } from './constants.mjs';
55
/**
66
* Creates a HackMD API client
77
* @param {import('./types.d.ts').AppConfig} config - Application configuration
8+
* @param {import('./types.d.ts').MeetingConfig} meetingConfig - Meeting configuration
89
* @returns {HackMDClient} Configured HackMD API client
910
*/
10-
export const createHackMDClient = ({ hackmd: { apiToken } }) => {
11-
return new HackMDAPI(apiToken);
11+
export const createHackMDClient = ({ hackmd: { apiToken } }, meetingConfig) => {
12+
// Use team-specific API endpoint if teamName is provided in meeting config
13+
const teamName = meetingConfig.properties.HACKMD_TEAM_NAME;
14+
15+
const baseURL = teamName
16+
? `https://api.hackmd.io/v1/teams/${teamName}`
17+
: 'https://api.hackmd.io/v1';
18+
19+
return new HackMDAPI(apiToken, baseURL);
1220
};
1321

1422
/**
1523
* Creates a new meeting notes document in HackMD with appropriate tags
1624
* @param {HackMDAPI} hackmdClient - HackMD API client
1725
* @param {string} title - Document title
1826
* @param {string} content - Document content in Markdown
19-
* @param {import('./types.d.ts').MeetingConfig} meetingConfig - Meeting configuration for tags
2027
* @returns {Promise<HackMDNote>} Created note data with ID and URLs
2128
*/
22-
export const createMeetingNotesDocument = (
23-
hackmdClient,
24-
title,
25-
content,
26-
meetingConfig
27-
) => {
28-
const meetingTag =
29-
meetingConfig?.properties?.GROUP_NAME ??
30-
meetingConfig?.properties?.AGENDA_TAG;
31-
32-
const teamName = meetingConfig?.properties?.HACKMD_TEAM_NAME;
33-
29+
export const createMeetingNotesDocument = (hackmdClient, title, content) => {
3430
const noteOptions = {
3531
title,
3632
content,
37-
tags: [meetingTag, 'Meetings'],
33+
parentFolderId: '',
3834
...HACKMD_DEFAULT_PERMISSIONS,
3935
};
4036

41-
if (teamName) {
42-
return hackmdClient.createTeamNote(teamName, noteOptions);
43-
}
44-
45-
return hackmdClient.createNote(noteOptions);
37+
// apparently it can return either { note: {...} } or just {...}
38+
return hackmdClient
39+
.createNote(noteOptions)
40+
.then(response => response?.note ?? response);
4641
};
4742

4843
/**
4944
* Updates an existing meeting notes document in HackMD with retry logic
5045
* @param {HackMDClient} hackmdClient - HackMD API client
5146
* @param {string} noteId - HackMD note ID
5247
* @param {string} content - Updated document content in Markdown
53-
* @param {import('./types.d.ts').MeetingConfig} meetingConfig - Meeting configuration for team context
5448
* @returns {Promise<HackMDNote>} Updated note data
5549
*/
56-
export const updateMeetingNotesDocument = (
57-
hackmdClient,
58-
noteId,
59-
content,
60-
meetingConfig
61-
) => {
62-
const teamName = meetingConfig?.properties?.HACKMD_TEAM_NAME;
63-
64-
if (teamName) {
65-
return hackmdClient.updateTeamNote(teamName, noteId, { content });
66-
}
67-
68-
return hackmdClient.updateNote(noteId, { content });
50+
export const updateMeetingNotesDocument = (hackmdClient, noteId, content) => {
51+
// apparently it can return either { note: {...} } or just {...}
52+
return hackmdClient
53+
.updateNote(noteId, { content })
54+
.then(response => response?.note ?? response);
6955
};

0 commit comments

Comments
 (0)