{"id":18398365,"url":"https://github.com/jiayihu/gh-issues-for-comments","last_synced_at":"2026-04-15T20:02:05.522Z","repository":{"id":70105287,"uuid":"98465430","full_name":"jiayihu/gh-issues-for-comments","owner":"jiayihu","description":"🐈 Automatically create Github issues to use as blog comments","archived":false,"fork":false,"pushed_at":"2017-07-27T21:16:23.000Z","size":30,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-25T21:48:04.359Z","etag":null,"topics":["comments","github","github-pages"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jiayihu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-07-26T20:59:31.000Z","updated_at":"2023-02-10T11:46:41.000Z","dependencies_parsed_at":"2023-06-25T23:34:48.491Z","dependency_job_id":null,"html_url":"https://github.com/jiayihu/gh-issues-for-comments","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jiayihu/gh-issues-for-comments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiayihu%2Fgh-issues-for-comments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiayihu%2Fgh-issues-for-comments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiayihu%2Fgh-issues-for-comments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiayihu%2Fgh-issues-for-comments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiayihu","download_url":"https://codeload.github.com/jiayihu/gh-issues-for-comments/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiayihu%2Fgh-issues-for-comments/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267960841,"owners_count":24172508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["comments","github","github-pages"],"created_at":"2024-11-06T02:21:44.071Z","updated_at":"2026-04-15T20:02:05.426Z","avatar_url":"https://github.com/jiayihu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gh-issues-for-comments\n\n[![npm](https://img.shields.io/npm/v/gh-issues-for-comments.svg)](https://www.npmjs.com/package/gh-issues-for-comments)\n\nAutomatically open a **Github issue as blog comments** for every articles of your blog. It also creates a `gh-comments.json` file to keep track of created issues for future executions and to open issues only for new articles.\n\nThis package is useful if you have a statically generated blog, such as [Jekyll](https://jekyllrb.com) or [Metalsmith](http://www.metalsmith.io), and you want to use Github issues as comments instead of the evil `Disqus`. For more details read [Using and automating GitHub issues as blog comments](http://blog.jiayihu.net/using-and-automating-github-issues-as-blog-comments/) or [Replacing Disqus with Github Comments](http://donw.io/post/github-comments/).\n\n## Install\n\n```\nnpm install gh-issues-for-comments --save\n```\n\n## Usage\n\n```javascript\nimport ghComments from 'gh-issues-for-comments';\n\n// Array of articles with any shape you like, for example obtained from Markdown files. \n// If you use default options each article must have 'id' and 'title' properties\nconst articles = [\n  { id: 1, title: 'Hello world' }, \n  { id: 2, title: 'Hello world 2' }\n];\n\nghComments(articles, {\n  username: 'jiayihu',\n  repo: 'blog',\n  token: '123GithubOAuthToken',\n})\n  .then(createdIssues =\u003e console.log(createdIssues))\n  .catch(error =\u003e console.error('Error with issues creation', error));\n```\n\n## API\n\n### ghComments(articles, options): Promise\n\nCreate a Github issue for every article without a comments issue yet. Returns a `Promise` with the updated map with `\u003carticle, issueId\u003e` pairs. It's the same object saved in `gh-comments.json`.\n\n`articles` is an `Array` of articles objects with any shape. Each article will be used to return the data for its issue in `getIssue(article)` option.\n\n`options` has the following shape:\n\n- **options.username** (*required*)\n  \n  Type: `string`\n  \n  Github username\n\n- **options.repo** (*required*)\n  \n  Type: `string`\n  \n  Github repository name\n\n- **options.token** (*required*)\n  \n  Type: `string`\n  \n  Github OAuth access token. Read [here](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) for more details. The only `scope` needed by the package is `public_repo`.\n\n- **options.idProperty** (*optional*)\n  \n  Type: `string`\n\n  Default value: `id`\n  \n  Article property to use as unique id. If an id is not available, it's recommended to use something meaninful but not likely to change like the filepath or title.\n\n- **options.jsonPath** (*optional*)\n  \n  Type: `string`\n\n  Default value: `gh-comments.json`\n  \n  Path to the JSON file where articles issue ids are stored\n\n- **options.getIssue** (*optional*)\n  \n  Type: `Function`\n\n  Default value: \n  ```javascript\n  function getIssue(article) {\n    return {\n      title: `Comments: ${article.title}`,\n      body: `This issue is reserved for comments to **${article.title}**. Leave a comment below and it will be shown in the blog page.`,\n      labels: ['comments'],\n    };\n  }\n  ```\n  \n  Returns the issue data based on the article. If you want the article name, in the issue body, to be linked you can use the following value:\n\n  ```javascript\n  function getIssue(article) {\n    const formattedTitle = article.title.replace(/\\s/g, '-').toLowerCase();\n    const articleUrl = url.resolve('http://blog.jiayihu.net', formattedTitle);\n\n    return {\n      title: `Comments: ${article.title}`,\n      body: `This issue is reserved for comments to [${article.title}](${articleUrl}). Leave a comment below and it will be shown in the blog page.`,\n      labels: ['comments'],\n    };\n  },\n  ```\n\n## Avoid issue creation\n\nThe script won't open an issue for an article if it finds an `issueId` in `gh-comments.json` for *that* article. So for example you can add the following content to skip issue creation for `articles/angular-aot.html`.\n\n```json\n{\n  \"articles/angular-aot.html\": {\n    \"issueId\": -1\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiayihu%2Fgh-issues-for-comments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiayihu%2Fgh-issues-for-comments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiayihu%2Fgh-issues-for-comments/lists"}