From c2a6310699a700f2405d5536b8b4f794924c11d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Scoubeau?= Date: Wed, 8 Aug 2018 16:47:19 +0200 Subject: [PATCH] All default props are factories, closes #13 --- src/helpers/defaultHref.js | 10 ---------- src/helpers/description.js | 7 +++++++ src/helpers/href.js | 16 ++++++++++++++++ src/helpers/icon.js | 7 +++++++ src/helpers/title.js | 6 ++++++ src/providers/Facebook.vue | 6 +++--- src/providers/GooglePlus.vue | 6 ++++-- src/providers/Line.vue | 6 ++++-- src/providers/LinkedIn.vue | 13 +++++++------ src/providers/LiveJournal.vue | 9 ++++++--- src/providers/MoiMir.vue | 17 +++++++++-------- src/providers/Odnoklassniki.vue | 9 +++++---- src/providers/Pinterest.vue | 14 +++++++------- src/providers/Reddit.vue | 9 ++++++--- src/providers/Telegram.vue | 6 +++--- src/providers/Tumblr.vue | 13 +++++++------ src/providers/Twitter.vue | 9 ++++++--- src/providers/Viber.vue | 6 ++++-- src/providers/Vkontakte.vue | 18 +++++++++--------- src/providers/WhatsApp.vue | 6 +++--- 20 files changed, 119 insertions(+), 74 deletions(-) delete mode 100644 src/helpers/defaultHref.js create mode 100644 src/helpers/description.js create mode 100644 src/helpers/href.js create mode 100644 src/helpers/icon.js create mode 100644 src/helpers/title.js diff --git a/src/helpers/defaultHref.js b/src/helpers/defaultHref.js deleted file mode 100644 index f904202..0000000 --- a/src/helpers/defaultHref.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * default page url prop value - * @return {String} document location href without hash - */ -export default function defaultHref() { - return document.location.href.replace( - document.location.hash, - '' - ); -} diff --git a/src/helpers/description.js b/src/helpers/description.js new file mode 100644 index 0000000..1e6a70e --- /dev/null +++ b/src/helpers/description.js @@ -0,0 +1,7 @@ +/** + * @return {String} description meta content + */ + export function metaDescription() { + const meta = document.querySelector('meta[name="description"]') + return meta ? meta.content : '' +} diff --git a/src/helpers/href.js b/src/helpers/href.js new file mode 100644 index 0000000..099f47c --- /dev/null +++ b/src/helpers/href.js @@ -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; +} diff --git a/src/helpers/icon.js b/src/helpers/icon.js new file mode 100644 index 0000000..b5ea97a --- /dev/null +++ b/src/helpers/icon.js @@ -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 : '' +} diff --git a/src/helpers/title.js b/src/helpers/title.js new file mode 100644 index 0000000..64169e5 --- /dev/null +++ b/src/helpers/title.js @@ -0,0 +1,6 @@ +/** + * @return {String} document title + */ + export function documentTitle() { + return document.title; +} diff --git a/src/providers/Facebook.vue b/src/providers/Facebook.vue index beb8347..ad2abe4 100644 --- a/src/providers/Facebook.vue +++ b/src/providers/Facebook.vue @@ -19,18 +19,18 @@