Skip to content

Commit

Permalink
All default props are factories, closes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
qur2 authored and Aurelien Scoubeau committed Aug 10, 2018
1 parent 95087a0 commit c2a6310
Show file tree
Hide file tree
Showing 20 changed files with 119 additions and 74 deletions.
10 changes: 0 additions & 10 deletions src/helpers/defaultHref.js

This file was deleted.

7 changes: 7 additions & 0 deletions src/helpers/description.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @return {String} description meta content
*/
export function metaDescription() {
const meta = document.querySelector('meta[name="description"]')
return meta ? meta.content : ''
}
16 changes: 16 additions & 0 deletions src/helpers/href.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @return {String} document location href without hash
*/
export function documentHrefWithoutHash() {
return document.location.href.replace(
document.location.hash,
''
);
}

/**
* @return {String} document location
*/
export function documentHref() {
return document.location.href;
}
7 changes: 7 additions & 0 deletions src/helpers/icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @return {String} apple-touch-icon link source
*/
export function linkAppleTouchIcon() {
const link = document.querySelector('link[rel="apple-touch-icon"]')
return link ? link.src : ''
}
6 changes: 6 additions & 0 deletions src/helpers/title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @return {String} document title
*/
export function documentTitle() {
return document.title;
}
6 changes: 3 additions & 3 deletions src/providers/Facebook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
</template>

<script>
import defaultHref from '../helpers/defaultHref';
import {documentHrefWithoutHash} from '../helpers/href';
export default {
name: 'VueGoodshareFacebook',
props: {
page_url: {
type: String,
default: defaultHref
default: documentHrefWithoutHash
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
6 changes: 4 additions & 2 deletions src/providers/GooglePlus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
</template>

<script>
import {documentHref} from '../helpers/href';
export default {
name: 'VueGoodshareGooglePlus',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
6 changes: 4 additions & 2 deletions src/providers/Line.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
</template>

<script>
import {documentHref} from '../helpers/href';
export default {
name: 'VueGoodshareLine',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
13 changes: 7 additions & 6 deletions src/providers/LinkedIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,28 @@
</template>

<script>
// Variables
const description = document.querySelector('meta[name="description"]')
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
import {metaDescription} from '../helpers/description';
export default {
name: 'VueGoodshareLinkedIn',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
page_description: {
type: String,
default: (description) ? description.content : ''
default: metaDescription
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
9 changes: 6 additions & 3 deletions src/providers/LiveJournal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
</template>

<script>
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
export default {
name: 'VueGoodshareLiveJournal',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
17 changes: 9 additions & 8 deletions src/providers/MoiMir.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,33 @@
</template>

<script>
// Variables
const description = document.querySelector('meta[name="description"]')
const image = document.querySelector('link[rel="apple-touch-icon"]')
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
import {metaDescription} from '../helpers/description';
import {linkAppleTouchIcon} from '../helpers/icon';
export default {
name: 'VueGoodshareMoiMir',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
page_description: {
type: String,
default: (description) ? description.content : ''
default: metaDescription
},
page_image: {
type: String,
default: (image) ? image.src : ''
default: linkAppleTouchIcon
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
9 changes: 5 additions & 4 deletions src/providers/Odnoklassniki.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@
</template>

<script>
import defaultHref from '../helpers/defaultHref';
import {documentHrefWithoutHash} from '../helpers/href';
import {documentTitle} from '../helpers/title';
export default {
name: 'VueGoodshareOdnoklassniki',
props: {
page_url: {
type: String,
default: defaultHref
default: documentHrefWithoutHash
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
14 changes: 7 additions & 7 deletions src/providers/Pinterest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@
</template>

<script>
// Variables
const description = document.querySelector('meta[name="description"]')
const image = document.querySelector('link[rel="apple-touch-icon"]')
import {documentHref} from '../helpers/href';
import {metaDescription} from '../helpers/description';
import {linkAppleTouchIcon} from '../helpers/icon';
export default {
name: 'VueGoodsharePinterest',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_description: {
type: String,
default: (description) ? description.content : ''
default: metaDescription
},
page_image: {
type: String,
default: (image) ? image.src : ''
default: linkAppleTouchIcon
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
9 changes: 6 additions & 3 deletions src/providers/Reddit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@
</template>

<script>
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
export default {
name: 'VueGoodshareReddit',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
6 changes: 3 additions & 3 deletions src/providers/Telegram.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
</template>

<script>
import defaultHref from '../helpers/defaultHref';
import {documentHrefWithoutHash} from '../helpers/href';
export default {
name: 'VueGoodshareTelegram',
props: {
page_url: {
type: String,
default: defaultHref
default: documentHrefWithoutHash
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
13 changes: 7 additions & 6 deletions src/providers/Tumblr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,28 @@
</template>

<script>
// Variables
const description = document.querySelector('meta[name="description"]')
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
import {metaDescription} from '../helpers/description';
export default {
name: 'VueGoodshareTumblr',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
page_description: {
type: String,
default: (description) ? description.content : ''
default: metaDescription
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
9 changes: 6 additions & 3 deletions src/providers/Twitter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
</template>

<script>
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
export default {
name: 'VueGoodshareTwitter',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
Loading

0 comments on commit c2a6310

Please sign in to comment.