@karaoke-cms/module-comments 0.10.3 → 0.11.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 +30 -15
- package/package.json +17 -4
- package/src/css-contract.ts +5 -0
- package/src/index.ts +59 -0
package/README.md
CHANGED
|
@@ -2,33 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
Giscus comments module for karaoke-cms. Embeds GitHub Discussion threads on blog posts and docs pages.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @karaoke-cms/module-comments
|
|
9
|
+
```
|
|
8
10
|
|
|
9
|
-
## Usage
|
|
11
|
+
## Usage
|
|
10
12
|
|
|
11
13
|
```ts
|
|
12
14
|
// karaoke.config.ts
|
|
13
15
|
import { defineConfig } from '@karaoke-cms/astro';
|
|
16
|
+
import { comments } from '@karaoke-cms/module-comments';
|
|
14
17
|
|
|
15
18
|
export default defineConfig({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
modules: [
|
|
20
|
+
comments({
|
|
21
|
+
repo: 'owner/repo',
|
|
22
|
+
repoId: 'R_...',
|
|
23
|
+
category: 'General',
|
|
24
|
+
categoryId: 'DIC_...',
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
24
27
|
});
|
|
25
28
|
```
|
|
26
29
|
|
|
27
30
|
Get `repoId` and `categoryId` from [giscus.app](https://giscus.app) after enabling GitHub Discussions on your repository.
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
## Per-post override
|
|
33
|
+
|
|
34
|
+
Individual posts and docs can disable comments via frontmatter:
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
---
|
|
38
|
+
title: My Post
|
|
39
|
+
comments: false
|
|
40
|
+
---
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## CSS contract
|
|
30
44
|
|
|
31
|
-
|
|
45
|
+
Themes must implement the `.comments` class:
|
|
32
46
|
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
| Class | Description | Required |
|
|
48
|
+
|-------|-------------|----------|
|
|
49
|
+
| `comments` | Comments section wrapper (Giscus embed) | Yes |
|
package/package.json
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karaoke-cms/module-comments",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.2",
|
|
5
5
|
"description": "Giscus comments module for karaoke-cms",
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.ts"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src/"
|
|
12
|
+
],
|
|
6
13
|
"keywords": [
|
|
7
14
|
"astro",
|
|
8
15
|
"cms",
|
|
9
16
|
"comments",
|
|
10
|
-
"giscus"
|
|
17
|
+
"giscus",
|
|
18
|
+
"karaoke-cms"
|
|
11
19
|
],
|
|
12
20
|
"peerDependencies": {
|
|
13
|
-
"astro": ">=6.0.0"
|
|
21
|
+
"astro": ">=6.0.0",
|
|
22
|
+
"@karaoke-cms/contracts": "^0.11.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"astro": "^6.0.8",
|
|
26
|
+
"@karaoke-cms/contracts": "0.11.2"
|
|
14
27
|
},
|
|
15
28
|
"scripts": {
|
|
16
|
-
"test": "echo \"
|
|
29
|
+
"test": "echo \"No tests — module is a factory only\""
|
|
17
30
|
}
|
|
18
31
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ModuleInstance } from '@karaoke-cms/contracts';
|
|
2
|
+
import { cssContract } from './css-contract.js';
|
|
3
|
+
|
|
4
|
+
export { cssContract } from './css-contract.js';
|
|
5
|
+
|
|
6
|
+
export interface CommentsConfig {
|
|
7
|
+
/** GitHub repo in "owner/repo" format */
|
|
8
|
+
repo: string;
|
|
9
|
+
repoId: string;
|
|
10
|
+
/** GitHub Discussions category name. Default: 'General' */
|
|
11
|
+
category?: string;
|
|
12
|
+
categoryId?: string;
|
|
13
|
+
/** When false, this module is excluded from the build. Default: true. */
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Comments module — Giscus GitHub Discussions comments widget.
|
|
19
|
+
*
|
|
20
|
+
* Embeds a comments section on all blog posts and docs pages using
|
|
21
|
+
* [Giscus](https://giscus.app). Requires GitHub Discussions enabled on the repo.
|
|
22
|
+
*
|
|
23
|
+
* Get `repoId` and `categoryId` from [giscus.app](https://giscus.app) after
|
|
24
|
+
* enabling GitHub Discussions on your repository.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // karaoke.config.ts
|
|
28
|
+
* import { comments } from '@karaoke-cms/module-comments';
|
|
29
|
+
* export default defineConfig({
|
|
30
|
+
* modules: [
|
|
31
|
+
* comments({
|
|
32
|
+
* repo: 'owner/repo',
|
|
33
|
+
* repoId: 'R_...',
|
|
34
|
+
* category: 'General',
|
|
35
|
+
* categoryId: 'DIC_...',
|
|
36
|
+
* }),
|
|
37
|
+
* ],
|
|
38
|
+
* });
|
|
39
|
+
*/
|
|
40
|
+
export function comments(config: CommentsConfig): ModuleInstance {
|
|
41
|
+
return {
|
|
42
|
+
_type: 'module-instance',
|
|
43
|
+
id: 'comments',
|
|
44
|
+
mount: '',
|
|
45
|
+
enabled: config.enabled ?? true,
|
|
46
|
+
routes: [],
|
|
47
|
+
menuEntries: [],
|
|
48
|
+
cssContract,
|
|
49
|
+
hasDefaultCss: false,
|
|
50
|
+
defaultCssPath: undefined,
|
|
51
|
+
scaffoldPages: undefined,
|
|
52
|
+
meta: {
|
|
53
|
+
repo: config.repo,
|
|
54
|
+
repoId: config.repoId,
|
|
55
|
+
category: config.category ?? 'General',
|
|
56
|
+
categoryId: config.categoryId ?? '',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|