Skip to content

Commit

Permalink
✨ add vara
Browse files Browse the repository at this point in the history
  • Loading branch information
jalenzz committed Sep 12, 2024
1 parent 40538db commit 13d364c
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 14 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"marked": "^2.0.0",
"nprogress": "^0.2.0",
"v-tooltip": "2.1.2",
"vara": "^1.4.1",
"vue-scrollto": "^2.20.0",
"word-count": "^0.2.2"
},
Expand Down
51 changes: 49 additions & 2 deletions src/components/Author.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
/>
</g-link>

<h1 v-if="showTitle" class="author__site-title">
{{ $static.metadata.siteName }}
<h1 v-if="showTitle" class="author__site-title" id="author-title">
<!-- {{ $static.metadata.siteName }} -->
</h1>

<p class="author__intro">你终于来啦👻</p>
Expand Down Expand Up @@ -65,6 +65,40 @@ query {
<script>
export default {
props: ["showTitle"],
methods: {
initializeVara(selector, text, yPosition, duration) {
const fontSize =
window.screen.width < 700 ? 32 : window.screen.width < 1200 ? 56 : 72;
new this.$vara(
selector,
"https://cdn.jsdelivr.net/npm/[email protected]/fonts/Satisfy/SatisfySL.json",
[
{
text: text,
y: yPosition,
fromCurrentPosition: { y: false },
duration: duration,
id: "blog",
},
],
{
strokeWidth: 2,
color: "#000000",
fontSize: fontSize,
textAlign: "center",
}
);
},
},
mounted() {
this.$nextTick(() => {
// 查找 id 为 author-title 的元素
if (document.getElementById("author-title")) {
this.initializeVara("#author-title", "Hi, I'm Jalen", 10, 3000);
}
});
},
};
</script>

Expand Down Expand Up @@ -186,4 +220,17 @@ export default {
visibility visible
opacity 1
transition opacity 0.15s
#author-title
width 80%
margin 20px auto
*
margin 0
padding 0
.hidden
width 0
opacity 0
overflow hidden
</style>
6 changes: 6 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ import axios from "axios";
// NProgress
import NProgress from "nprogress";

// Vara
import Vara from "vara";

// The Client API can be used here. Learn more: gridsome.org/docs/client-api
export default function (Vue, { router, head, isClient }) {
head.htmlAttrs = { lang: "zh-Hans" };
Expand Down Expand Up @@ -100,4 +103,7 @@ export default function (Vue, { router, head, isClient }) {
router.afterEach((to, from) => {
NProgress.done();
});

// Vara
Vue.prototype.$vara = Vara;
}
37 changes: 27 additions & 10 deletions src/pages/About.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<div class="about-title">
<h1 class="about-title__text">About</h1>
<div class="about-title" id="about-title">
<!-- <h1 class="about-title__text">About</h1> -->
</div>

<div class="about content-box">
Expand All @@ -24,22 +24,18 @@
><font-awesome :icon="['fab', 'github']" /> jalenzz</a
>
/
<a
target="_blank"
class="about-me"
style="color: #efa371;">
<a target="_blank" class="about-me" style="color: #efa371">
<font-awesome :icon="['fas', 'envelope']" />
[email protected]</a
>

</p>

<p>
🫠 Ctrl CV Engineer <br />
😍 坚定的括号不换行党!<br />
🥳 最喜欢去陌生的城市走走看看<br />
😶‍🌫️ 信奉好看就是生产力!<br />
😆 like Emoji
😆 like Emoji
</p>

<h3 id="关于博客"><a href="#关于博客"></a>关于博客</h3>
Expand Down Expand Up @@ -121,7 +117,7 @@
</div>
</transition>

<Author class="post-author" />
<Author class="post-author" ref="authorComponent" />
</div>
</template>

Expand All @@ -144,7 +140,7 @@ export default {
},
data() {
return {
themeUrl: '',
themeUrl: "",
scrolledDist: 0,
};
},
Expand All @@ -155,6 +151,14 @@ export default {
}
},
},
mounted() {
this.$refs.authorComponent.initializeVara(
"#about-title",
"About",
50,
2000
);
},
created() {
if (process.isClient) {
window.addEventListener("scroll", this.handleScroll);
Expand Down Expand Up @@ -258,4 +262,17 @@ query {
.v[data-class=v] .vaction
display none !important
#about-title
width 80%
margin 20px auto
*
margin 0
padding 0
.hidden
width 0
opacity 0
overflow hidden
</style>
25 changes: 23 additions & 2 deletions src/pages/Friends.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<h1 class="friends-title text-center space-bottom">Friends</h1>
<h1 class="friends-title text-center space-bottom" id="friends-title"></h1>

<div class="friends-container text-center space-bottom">
<div class="friends-content">
Expand Down Expand Up @@ -32,7 +32,7 @@
<div id="disqus_thread" />
</div>

<Author class="post-author" />
<Author class="post-author" ref="authorComponent" />
</div>
</template>

Expand Down Expand Up @@ -107,6 +107,14 @@ export default {
],
};
},
mounted() {
this.$refs.authorComponent.initializeVara(
"#friends-title",
"Friends",
50,
2000
);
},
};
</script>

Expand Down Expand Up @@ -206,4 +214,17 @@ body[data-theme="dark"]
margin calc(var(--space) / 2) 0
font-size 0.9em
opacity 0.8
#friends-title
width 80%
margin 20px auto
*
margin 0
padding 0
.hidden
width 0
opacity 0
overflow hidden
</style>
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10187,6 +10187,11 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"

vara@^1.4.1:
version "1.4.1"
resolved "https://mirrors.huaweicloud.com/repository/npm/vara/-/vara-1.4.1.tgz#974272696f39682bc4da7cc2e2f73d5fd683c305"
integrity sha512-oX+D+jXIJTmdQb7+OeuhvxSvSJB1PG8X2mzI3u7wTbuJ4v2QskA2fNlkNnyI2883YBRmEoA6R9gJg4jHiVNvXQ==

vary@~1.1.2:
version "1.1.2"
resolved "https://mirrors.huaweicloud.com/repository/npm/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
Expand Down

0 comments on commit 13d364c

Please sign in to comment.