Skip to content

Commit 04f4c6f

Browse files
Initial commit
0 parents  commit 04f4c6f

11 files changed

+504
-0
lines changed

.babelrc

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"presets": [
3+
[
4+
"vue-app",
5+
{
6+
"modules": false
7+
}
8+
]
9+
],
10+
"env": {
11+
"test": {
12+
"presets": [
13+
[
14+
"vue-app",
15+
{
16+
"targets": {
17+
"node": 8
18+
}
19+
}
20+
]
21+
]
22+
}
23+
}
24+
}

.eslintrc.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
sourceType: 'module'
5+
},
6+
env: {
7+
browser: true,
8+
node: true,
9+
jest: true
10+
},
11+
extends: 'standard',
12+
plugins: [
13+
'jest'
14+
],
15+
rules: {
16+
// Allow paren-less arrow functions
17+
'arrow-parens': 0,
18+
// Allow async-await
19+
'generator-star-spacing': 0,
20+
// Allow debugger during development
21+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
22+
// Do not allow console.logs etc...
23+
'no-console': 2
24+
},
25+
globals: {
26+
'jest/globals': true,
27+
jasmine: true
28+
}
29+
}

.gitignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.idea/**
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pids
8+
*.pid
9+
*.seed
10+
*.pid.lock
11+
lib-cov
12+
coverage
13+
.nyc_output
14+
.grunt
15+
bower_components
16+
.lock-wscript
17+
build/Release
18+
node_modules/
19+
package-lock.json
20+
jspm_packages/
21+
typings/
22+
.npm
23+
.eslintcache
24+
.node_repl_history
25+
*.tgz
26+
.yarn-integrity
27+
.env
28+
.next
29+
dist

.travis.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: node_js
2+
node_js:
3+
- "8"
4+
- "9"
5+
- "10"
6+
cache:
7+
npm: true
8+
directories:
9+
- node_modules
10+
install:
11+
- npm install
12+
script:
13+
- npm t
14+
after_success:
15+
- npm run coverage

CONTRIBUTING.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Contributing to VueNextLevelScroll
2+
3+
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
4+
2. Install the dependencies: `npm install`.
5+
3. Develop your feature/bugfix.
6+
4. Be sure to format your commit messages according to the [commit guidelines](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits). See more about this on [Conventional commits](http://conventionalcommits.org/)
7+
5. Add tests into `test` directory and try them with `npm test`.
8+
6. Send the PR!

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Alexander Lichter ([@manniL](https://github.com/manniL))
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# VueIfBot - Hide stuff from bots (especially cookie consents) :no_entry_sign::eyes:
2+
3+
<p align="center">
4+
<a href="https://travis-ci.com/Developmint/vue-if-bot"><img src="https://travis-ci.com/Developmint/vue-if-bot.svg?branch=master" alt="Build Status"></a>
5+
<a href="https://codecov.io/gh/Developmint/vue-if-bot"><img src="https://codecov.io/gh/Developmint/vue-if-bot/branch/master/graph/badge.svg" alt="Code coverage"></a>
6+
<a href="https://www.npmjs.com/package/vue-if-bot"><img src="https://img.shields.io/npm/dm/vue-if-bot.svg" alt="Downloads"></a>
7+
<a href="https://www.npmjs.com/package/vue-if-bot"><img src="https://img.shields.io/npm/v/vue-if-bot.svg" alt="Version"></a>
8+
<a href="https://www.npmjs.com/package/vue-if-bot"><img src="https://img.shields.io/npm/l/vue-if-bot.svg" alt="License"></a>
9+
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="We use Conventional Commits"></a>
10+
</p>
11+
12+
> Lightweight component to hide/show content to clients based on the user agent
13+
14+
## :interrobang: Why this component exists
15+
16+
As you know, the GDPR is coming (or more likely: is already applicable when you read this).
17+
With it, a lot of information banners, consents concerning cookies, privacy policies and so on.
18+
19+
The average user will see those banners once (a year, that's the law), but search engine crawlers
20+
will always see it (as they don't have any cookies and won't click on it). On **every page**.
21+
Depending on the screen size they take, this could be annoying and even influence your SEO (negatively).
22+
23+
So **stop it now!** With **VueIfBot**.
24+
25+
Having any other cases you need this component? Feel free to share!
26+
27+
## :fire: Features
28+
29+
- **Tiny functional component**
30+
- SSR-safe (works with Nuxt.js)
31+
- Well tested and **documented**
32+
- Compatible with Node 8.0+
33+
- Vue as the only dependency
34+
- Highly customizable
35+
36+
## :mag_right: Getting started
37+
38+
39+
### :package: Through NPM
40+
41+
```
42+
$ npm install vue-if-bot
43+
```
44+
45+
#### Synchronous import
46+
47+
```js
48+
import VueIfBot from 'vue-if-bot'
49+
50+
export default {
51+
components: {
52+
VueIfBot
53+
}
54+
}
55+
56+
```
57+
58+
#### Async import
59+
60+
```js
61+
export default {
62+
components: {
63+
VueIfBot: () => import('vue-if-bot')
64+
}
65+
}
66+
67+
```
68+
69+
### :link::x: Using a CDN
70+
71+
Sorry! No CDN available for VueIfBot right now.
72+
73+
## :hammer_and_wrench: Usage
74+
75+
### Handling
76+
77+
By default, all children of the component are **not** displayed to bots.
78+
VueIfBot detects bots by testing their user agent against the regex `/bot|googlebot|crawler|spider|robot|crawling/i`
79+
80+
### Prop overview
81+
82+
83+
| Prop | Type | Comment |
84+
| --- | --- | --- |
85+
| invert | Boolean | Inverts the behavior (shows content **only to bots**)|
86+
| regex | RegExp | Change the user agent regex to your own (eg `/test/i`)|
87+
88+
89+
### Example usage
90+
91+
```js
92+
<vue-if-bot>
93+
<h1>This won't be visible for bots</h1>
94+
</vue-if-bot>
95+
```
96+
## :gear: Contributing
97+
98+
Please see our [CONTRIBUTING.md](./CONTRIBUTING.md)
99+
100+
101+
## :bookmark_tabs: License
102+
103+
[MIT License](./LICENSE.md) - Copyright (c) Developmint - Alexander Lichter

commitlint.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] }

lib/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
functional: true,
3+
render (h, { children, props: { regex, invert } }) {
4+
const botRegex = regex || /bot|googlebot|crawler|spider|robot|crawling/i
5+
const isBot = process.server ? true : navigator.userAgent && botRegex.test(navigator.userAgent)
6+
const shouldShow = invert ? isBot : !isBot
7+
8+
return h('div', {}, shouldShow ? children : [h('div')])
9+
}
10+
}

package.json

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"name": "vue-if-bot",
3+
"version": "1.0.0",
4+
"description": "Hide stuff from bots (especially cookie consents)",
5+
"author": "Alexander Lichter <[email protected]>",
6+
"license": "MIT",
7+
"main": "lib/index.js",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/Developmint/vue-if-bot"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/Developmint/vue-if-bot/issues"
14+
},
15+
"scripts": {
16+
"lint": "eslint lib test",
17+
"test": "npm run lint && jest",
18+
"release": "standard-version && git push --follow-tags && npm publish",
19+
"commitlint": "commitlint -e $GIT_PARAMS",
20+
"coverage": "codecov"
21+
},
22+
"files": [
23+
"lib"
24+
],
25+
"keywords": [
26+
"vue",
27+
"vuejs",
28+
"bot",
29+
"user-agent",
30+
"useragent",
31+
"hide",
32+
"consent",
33+
"cookie",
34+
"component",
35+
"plugin"
36+
],
37+
"engines": {
38+
"node": ">=8.0.0",
39+
"npm": ">=5.0.0"
40+
},
41+
"jest": {
42+
"moduleFileExtensions": [
43+
"js",
44+
"json",
45+
"vue"
46+
],
47+
"transform": {
48+
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
49+
".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
50+
},
51+
"moduleNameMapper": {
52+
"^@/(.*)$": "<rootDir>/lib/$1"
53+
},
54+
"snapshotSerializers": [
55+
"<rootDir>/node_modules/jest-serializer-vue"
56+
],
57+
"collectCoverage": true,
58+
"coveragePathIgnorePatterns": [
59+
"/node_modules/"
60+
]
61+
},
62+
"devDependencies": {
63+
"@commitlint/cli": "^6.1.3",
64+
"@commitlint/config-conventional": "^6.1.3",
65+
"@vue/server-test-utils": "^1.0.0-beta.15",
66+
"@vue/test-utils": "^1.0.0-beta.15",
67+
"babel-core": "^6.26.0",
68+
"babel-jest": "^22.4.4",
69+
"babel-loader": "^7.1.2",
70+
"babel-preset-vue-app": "^2.0.0",
71+
"cheerio": "^1.0.0-rc.2",
72+
"codecov": "latest",
73+
"cross-env": "^5.1.5",
74+
"eslint": "^4.19.1",
75+
"eslint-config-standard": "^12.0.0-alpha.0",
76+
"eslint-plugin-import": "^2.12.0",
77+
"eslint-plugin-jest": "latest",
78+
"eslint-plugin-node": "^6.0.1",
79+
"eslint-plugin-promise": "^3.7.0",
80+
"eslint-plugin-standard": "^3.1.0",
81+
"husky": "^1.0.0-rc.2",
82+
"jest": "latest",
83+
"jest-serializer-vue": "^1.0.0",
84+
"jsdom": "latest",
85+
"standard-version": "latest",
86+
"vue-jest": "^2.6.0",
87+
"vue-loader": "^15.1.0",
88+
"vue-router": "^3.0.1",
89+
"vue-server-renderer": "^2.5.16",
90+
"vue-template-compiler": "^2.5.16",
91+
"webpack": "^4.8.3",
92+
"webpack-dev-server": "^3.1.4"
93+
},
94+
"husky": {
95+
"hooks": {
96+
"pre-commit": "npm run lint",
97+
"commit-msg": "npm run commitlint"
98+
}
99+
},
100+
"dependencies": {
101+
"vue": "^2.5.16"
102+
}
103+
}

0 commit comments

Comments
 (0)