Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abhyudayasharma/react-git-info
Get Git commit information in your React App
https://github.com/abhyudayasharma/react-git-info
babel-plugin-macros create-react-app gatsby gatsbyjs git git-branch git-commit git-info git-tags hacktoberfest react typescript-support
Last synced: 11 days ago
JSON representation
Get Git commit information in your React App
- Host: GitHub
- URL: https://github.com/abhyudayasharma/react-git-info
- Owner: AbhyudayaSharma
- License: mit
- Created: 2020-01-18T06:57:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-10-12T15:42:38.000Z (about 2 years ago)
- Last Synced: 2024-10-08T13:20:18.077Z (30 days ago)
- Topics: babel-plugin-macros, create-react-app, gatsby, gatsbyjs, git, git-branch, git-commit, git-info, git-tags, hacktoberfest, react, typescript-support
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/react-git-info
- Size: 60.5 KB
- Stars: 51
- Watchers: 3
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-git-info
[![npm version](https://badge.fury.io/js/react-git-info.svg)](https://badge.fury.io/js/react-git-info)
![Node.js CI](https://github.com/AbhyudayaSharma/react-git-info/workflows/Node.js%20CI/badge.svg)Get git commit information in your React Application as a JavaScript object.
No configuration necessary if you use create-react-app.## Usage
You need to install this repository as an NPM `devDependency`:
```bash
npm install --save-dev react-git-info
```After that you can import the information to your static React files.
```jsx
import GitInfo from 'react-git-info/macro';const gitInfo = GitInfo();
console.log(gitInfo.branch);
console.log(gitInfo.tags);
console.log(gitInfo.commit.date);
console.log(gitInfo.commit.hash);
console.log(gitInfo.commit.message);
console.log(gitInfo.commit.shortHash);// or from JSX
{gitInfo.commit.message}
```### TypeScript Support
There is built-in TypeScript support, you won't have to install external types.
## How it works
This package uses a `babel-plugin-macros` macro that is preconfigured when
you're using a recent version of `create-react-app`.