https://github.com/fatihtatoglu/gulp-html-anchor-rewriter
A gulp plugin for editing anchor element in the HTML files.
https://github.com/fatihtatoglu/gulp-html-anchor-rewriter
Last synced: 11 months ago
JSON representation
A gulp plugin for editing anchor element in the HTML files.
- Host: GitHub
- URL: https://github.com/fatihtatoglu/gulp-html-anchor-rewriter
- Owner: fatihtatoglu
- License: mit
- Created: 2022-03-22T09:02:31.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-02T15:32:57.000Z (over 4 years ago)
- Last Synced: 2025-08-09T07:34:59.513Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 575 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Html Anchor Rewriter Gulp Plugin
This is the simple plugin to re-write anchor elements such as adding new attributes.
## Motivation
While developing another gulp plugin ([1]), I have needed re-writing anchor elements for the SEO. After reading some articles, I decided develop a gulp plugin for re-writing anchor elements.
 [](http://hits.dwyl.com/fatihtatoglu/gulp-html-anchor-rewriter)   [](https://sonarcloud.io/summary/new_code?id=fatihtatoglu_gulp-html-anchor-rewriter) [](https://sonarcloud.io/summary/new_code?id=fatihtatoglu_gulp-html-anchor-rewriter) [](https://sonarcloud.io/summary/new_code?id=fatihtatoglu_gulp-html-anchor-rewriter) 
## Challenges
The gulp system has dynamic and usefull plugin system. However, some times finding a plugin will be a challenge and writing a custom plugin is already a challenge.
The gulp suggets a guideline for writing a plugin. This time, I want to follow it ([2]). In this challenge, I wrote tests for validating plugin and I have used [Mocha]([3]) and [Chai]([4]).
    
## Installation
```bash
npm install --save-dev gulp-html-anchor-rewriter
```
## Usage
```js
const { src, dest } = require("gulp");
const anchorRewriter = require("gulp-html-anchor-rewriter");
exports.default = function () {
return src("./test/*.html")
.pipe(anchorRewriter({
"rel": "nofollow"
}))
.pipe(dest("./output"));
};
```
## Options
Without any options plugin throws an exception.
| Name | Type | Description |
|---|---|---|
| keyword | string, string[] | For searching the anchor element href attribute value. If the href contains the keyword, the anchor will be processed. |
| rel | string | For adding rel attribute. |
| target | string | For adding target attribute. |
| whiteList | boolean | Indicates whether the white-list mode is enabled. |
[1]: https://github.com/fatihtatoglu/enginaer
[2]: https://github.com/gulpjs/gulp/tree/master/docs/writing-a-plugin
[3]: https://mochajs.org/
[4]: https://www.chaijs.com/
## Testing
For local testing, can be used unit tests.
```bash
$> npm install
$> npm test
```
## Support
For supporting me, you can add an issue for bug cases or new feature requests.