You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
4.3 KiB

4 years ago
4 years ago
  1. <!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->
  2. # github-calendar.js
  3. [![Version](https://img.shields.io/npm/v/github-calendar.svg)](https://www.npmjs.com/package/github-calendar) [![Downloads](https://img.shields.io/npm/dt/github-calendar.svg)](https://www.npmjs.com/package/github-calendar)
  4. > Embed your GitHub contributions calendar anywhere.
  5. Everybody<sup><sup>well, haters gonna hate</sup></sup> loves GitHub and everybody loves stats. So, why not making the GitHub contributions calendar available for being embeded in your web pages? Now [you can](https://bloggify.github.io/github-calendar/example). :tada:
  6. [![](https://i.imgur.com/tJjRpuN.png)](https://bloggify.github.io/github-calendar/example)
  7. ## :cloud: Installation
  8. Check out the [`dist`](/dist) directory to download the needed files and include them on your page.
  9. If you're using this module in a CommonJS environment, you can install it using `npm` or `yarn` and `require` it:
  10. ```sh
  11. # Using npm
  12. npm install --save github-calendar
  13. # Using yarn
  14. yarn add github-calendar
  15. ```
  16. ```html
  17. <!-- Include the library. -->
  18. <script
  19. src="https://unpkg.com/github-calendar@latest/dist/github-calendar.min.js">
  20. </script>
  21. <!-- Optionally, include the theme (if you don't want to struggle to write the CSS) -->
  22. <link
  23. rel="stylesheet"
  24. href="https://unpkg.com/github-calendar@latest/dist/github-calendar-responsive.css"
  25. />
  26. <!-- Prepare a container for your calendar. -->
  27. <div class="calendar">
  28. <!-- Loading stuff -->
  29. Loading the data just for you.
  30. </div>
  31. <script>
  32. GitHubCalendar(".calendar", "your-username");
  33. // or enable responsive functionality:
  34. GitHubCalendar(".calendar", "your-username", { responsive: true });
  35. // Use a proxy
  36. GitHubCalendar(".calendar", "your-username", {
  37. proxy (username) {
  38. return fetch(`https://your-proxy.com/github?user=${username}`)
  39. }
  40. }).then(r => r.text())
  41. </script>
  42. ```
  43. [Here](https://bloggify.github.io/github-calendar/example/) you can see this example in action.
  44. ## :question: Get Help
  45. There are few ways to get help:
  46. 1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
  47. 2. For bug reports and feature requests, open issues. :bug:
  48. ## :memo: Documentation
  49. ### `GitHubCalendar(container, username, options)`
  50. Brings the contributions calendar from GitHub (provided username) into your page.
  51. #### Params
  52. - **String|HTMLElement** `container`: The calendar container (query selector or the element itself).
  53. - **String** `username`: The GitHub username.
  54. - **Object** `options`: An object containing the following fields:
  55. - `summary_text` (String): The text that appears under the calendar (defaults to: `"Summary of
  56. pull requests, issues opened, and commits made by <username>"`).
  57. - `proxy` (Function): A function that receives as argument the username (string) and should return a promise resolving the HTML content of the contributions page.
  58. The default is using @Bloggify's APIs.
  59. - `global_stats` (Boolean): If `false`, the global stats (total, longest and current streaks) will not be calculated and displayed. By default this is enabled.
  60. - `responsive` (Boolean): If `true`, the graph is changed to scale with the container. Custom CSS should be applied to the element to scale it appropriately. By default this is disabled.
  61. - `tooltips` (Boolean): If `true`, tooltips will be shown when hovered over calendar days. By default this is disabled.
  62. - `cache` (Number) The cache time in seconds.
  63. #### Return
  64. - **Promise** A promise returned by the `fetch()` call.
  65. ## :yum: How to contribute
  66. Have an idea? Found a bug? See [how to contribute][contributing].
  67. ## :dizzy: Where is this library used?
  68. If you are using this library in one of your projects, add it in this list. :sparkles:
  69. - `@pengliheng/github-report`
  70. - `@axetroy/react-github-calendar`
  71. - `github-alike-calendar`
  72. - `@philipwhiuk/react-github-calendar`
  73. ## :scroll: License
  74. [MIT][license] © [Bloggify][website]
  75. [license]: /LICENSE
  76. [website]: https://bloggify.org
  77. [contributing]: /CONTRIBUTING.md
  78. [docs]: /DOCUMENTATION.md