1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-12-22 10:08:54 +00:00

feat(cheatsheet): handle logic for share buttons

This commit is contained in:
Julien 2018-09-10 11:46:53 +02:00
parent f5dabeff07
commit 03e915e30c
3 changed files with 26 additions and 3 deletions

View File

@ -24,6 +24,7 @@
.c-base-cheatsheet__share
base-share(
v-for="network in networks"
@click="onShare"
:key="network"
:network="network"
class="c-base-cheatsheet__network"
@ -57,8 +58,30 @@ export default {
baseUrl: process.env.baseUrl,
// --> COMPONENTS <--
networks: ["Slack", "Messenger", "Telegram", "Twitter", "LinkedIn"]
networks: ["Telegram", "Twitter", "LinkedIn"]
};
},
methods: {
onShare(network) {
const link = this.link;
const socialNetwork = network.toLowerCase();
const technology = this.name;
let url = "";
let message = encodeURIComponent(
`Check this awesome cheatsheet about ${technology}: ${link} #${technology.toLowerCase()} #cheatsheet`
);
if (socialNetwork === "telegram") {
url = `https://telegram.me/share/url?url=${link}&text=${message}`;
} else if (socialNetwork === "twitter") {
url = `https://twitter.com/intent/tweet?text=${message}`;
} else if (socialNetwork === "linkedin") {
url = `https://www.linkedin.com/shareArticle?mini=true&url=${link}&source=LinkedIn`;
}
window.open(url);
}
}
};
</script>

View File

@ -70,7 +70,7 @@ $c: ".c-the-github-buttons";
#{$c} {
#{$c}__wrapper {
display: inline-block;
margin-bottom: 20px;
margin-bottom: 10px;
width: 100%;
#{$c}__button {
@ -103,6 +103,7 @@ $c: ".c-the-github-buttons";
#{$c} {
display: flex;
justify-content: center;
margin-bottom: 0;
#{$c}__wrapper {
width: initial;

View File

@ -24,7 +24,6 @@
user="LeCoupa"
class="c-index__github-buttons"
)
section(
v-for="(category, index) in categories"
:key="category.name"