Skip to content

Commit 3e3f21c

Browse files
committed
event config can include description
1 parent b54de63 commit 3e3f21c

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import {
77
Event,
88
EventConfig,
99
Calendar,
10-
} from 'https://deno.land/x/[email protected].6/mod.ts';
10+
} from 'https://deno.land/x/[email protected].7/mod.ts';
1111

1212
const cfg1: EventConfig = {
13-
title: 'Write typescript',
13+
title: 'Write Typescript',
1414
beginDate: [2022, 9, 6, 9, 30],
1515
endDate: [2022, 9, 6, 10],
16+
description: 'Implement a module to generate .ics files',
1617
};
1718

1819
const cfg2: EventConfig = {

main.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ export class Event {
3737
}
3838
}
3939

40-
public toLines(): ContentLine[] {
40+
toLines(): ContentLine[] {
4141
const uid = crypto.randomUUID();
42-
const { title } = this.config;
42+
const { title, description } = this.config;
43+
44+
// Optional lines
45+
const optLines: ContentLine[] = [];
46+
if (description) optLines.push(['DESCRIPTION', description]);
4347

4448
return [
4549
eventBegin,
@@ -48,6 +52,7 @@ export class Event {
4852
['DTSTART', parseDate(this.config.beginDate)],
4953
['DTEND', parseDate(this.config.endDate!)],
5054
['SUMMARY', title],
55+
...optLines,
5156
eventEnd,
5257
];
5358
}
@@ -72,4 +77,5 @@ export interface EventConfig {
7277
beginDate: DateData;
7378
endDate?: DateData;
7479
duration?: number;
80+
description?: string;
7581
}

tests.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Deno.test({
77
title: 'test',
88
beginDate: [2022, 8, 1, 10, 10],
99
endDate: [2022, 8, 1, 11, 10],
10+
description: 'Hello',
1011
};
1112
const evt = new Event(cfg);
1213

@@ -33,9 +34,10 @@ Deno.test({
3334
name: 'doc',
3435
fn() {
3536
const cfg1: EventConfig = {
36-
title: 'Write typescript',
37+
title: 'Write Typescript',
3738
beginDate: [2022, 9, 6, 9, 30],
3839
endDate: [2022, 9, 6, 10],
40+
description: 'Implement a module to generate .ics files',
3941
};
4042

4143
const cfg2: EventConfig = {

0 commit comments

Comments
 (0)