Skip to content

Commit

Permalink
feat: better page title for home page
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Aug 18, 2023
1 parent 4b2c25f commit 9c09e57
Show file tree
Hide file tree
Showing 22 changed files with 99 additions and 61 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.2",
"vue3-click-away": "^1.2.4",
"vue3-lazyload": "^0.3.6",
"vue3-scroll-spy": "^1.0.8"
"vue3-lazyload": "^0.3.6"
},
"devDependencies": {
"@commitlint/cli": "^17.6.6",
Expand Down Expand Up @@ -73,6 +72,7 @@
"vite-plugin-html-transformer": "^4.0.0",
"vite-plugin-svg-icons": "^2.0.1",
"vue-easy-lightbox": "^1.16.0",
"vue-jest": "^3.0.7"
"vue-jest": "^3.0.7",
"vue3-scroll-spy": "^1.0.8"
}
}
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/Breadcrumbs.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<ul class="breadcrumbs flex flex-row gap-6 text-white z-50">
<ul class="breadcrumbs flex flex-row gap-6 text-white z-50 px-4">
<li>
{{ t('menu.home') }}
</li>
Expand Down
10 changes: 7 additions & 3 deletions src/components/Footer/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
</span>
</li>
</ul>
<ul class="flex flex-col min-w-[150px]">
<ul class="flex flex-col min-w-[150px] gap-1.5">
<li class="flex" v-if="enabledPlugin === 'waline'">
<span>
<SvgIcon
icon-class="hot"
class="mr-1 text-lg inline-block"
:svg-type="SvgTypes.fill"
stroke="currentColor"
/>
{{ t('settings.page-views-value') }}
</span>
Expand All @@ -90,7 +90,11 @@

<li v-if="runningDays" class="flex">
<span class="">
<SvgIcon icon-class="date" class="mr-1 text-lg inline-block" />
<SvgIcon
icon-class="date"
class="mr-1 text-lg inline-block"
stroke="currentColor"
/>
{{ t('settings.site-running-for') }}
</span>
<span class="flex-1 text-right"
Expand Down
26 changes: 16 additions & 10 deletions src/components/Post/PostStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
>
<span>
<SvgIcon
icon-class="clock-outline"
class="opacity-70"
icon-class="clock"
fill="none"
stroke="white"
height="1.25em"
Expand All @@ -17,7 +18,8 @@
</span>
<span>
<SvgIcon
icon-class="text-outline"
class="opacity-70"
icon-class="text"
fill="none"
stroke="white"
height="1.25em"
Expand All @@ -31,7 +33,7 @@
<!-- Waline -->
<span v-if="plugin === 'waline'">
<SvgIcon
class="h-5 w-5"
class="opacity-70"
icon-class="hot"
fill="none"
stroke="white"
Expand All @@ -46,7 +48,7 @@
</span>
<span v-if="comments && plugin === 'waline'">
<SvgIcon
class="h-5 w-5"
class="opacity-70"
icon-class="quote"
fill="none"
stroke="white"
Expand All @@ -63,7 +65,7 @@
<!-- Twikoo -->
<span v-if="plugin === 'twikoo'">
<SvgIcon
class="h-5 w-5"
class="opacity-70"
icon-class="hot"
fill="none"
stroke="white"
Expand All @@ -76,7 +78,7 @@
</span>
<span v-if="comments && plugin === 'twikoo'">
<SvgIcon
class="h-5 w-5"
class="opacity-70"
icon-class="quote"
fill="none"
stroke="white"
Expand All @@ -97,7 +99,7 @@
<!-- Valine -->
<span v-if="plugin === 'valine'">
<SvgIcon
class="h-5 w-5"
class="opacity-70"
icon-class="hot"
fill="none"
stroke="white"
Expand All @@ -121,7 +123,8 @@
<div v-else class="post-stats">
<span>
<SvgIcon
icon-class="clock-outline"
class="opacity-70"
icon-class="clock"
fill="none"
stroke="white"
height="1.25em"
Expand All @@ -133,8 +136,9 @@
</span>
<span>
<SvgIcon
icon-class="text-outline"
fill="none"
class="opacity-70"
icon-class="text"
fill="white"
stroke="white"
height="1.25em"
width="1.25em"
Expand All @@ -147,6 +151,7 @@
v-if="plugin === 'waline' || plugin === 'twikoo' || plugin === 'valine'"
>
<SvgIcon
class="opacity-70"
icon-class="hot"
fill="none"
stroke="white"
Expand All @@ -159,6 +164,7 @@
</span>
<span v-if="comments && (plugin === 'waline' || plugin === 'twikoo')">
<SvgIcon
class="opacity-70"
icon-class="quote"
fill="none"
stroke="white"
Expand Down
24 changes: 19 additions & 5 deletions src/components/Sidebar/src/Navigator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,45 @@
class="border-r-4 border-ob-deep-900 flex justify-center py-3 w-full hover:opacity-50 hover:text-ob transition-all cursor-pointer"
@click="goBack"
>
<SvgIcon class="inline-block text-3xl" icon-class="go-back" />
<SvgIcon
class="inline-block text-3xl"
icon-class="go-back"
fill="none"
stroke="currentColor"
/>
</li>
<li
class="border-r-4 border-ob-deep-900 flex justify-center py-3 w-full hover:opacity-50 hover:text-ob transition-all cursor-pointer"
@click="backToTop"
>
<SvgIcon class="inline-block text-3xl" icon-class="back-to-top" />
<SvgIcon
class="inline-block text-3xl"
icon-class="back-to-top"
fill="none"
stroke="currentColor"
/>
</li>
<li
v-if="comments"
class="flex justify-center py-3 w-full hover:opacity-50 hover:text-ob transition-all cursor-pointer"
@click="jumpToComments"
data-dia="jump-to-comment"
>
<SvgIcon class="inline-block text-3xl" icon-class="quote" />
<SvgIcon
class="inline-block text-3xl"
icon-class="quote"
fill="none"
stroke="currentColor"
/>
</li>
</ul>
</template>

<script lang="ts">
import { computed, defineComponent, ref } from 'vue'
import { defineComponent } from 'vue'
import { useRouter } from 'vue-router'
import SvgIcon from '@/components/SvgIcon/index.vue'
import useJumpToEle from '@/hooks/useJumpToEle'
import useCommentPlugin from '@/hooks/useCommentPlugin'
export default defineComponent({
name: 'Navigator',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/src/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
>
<p
v-if="authorData.description"
class="flex-1 pt-6 px-8 w-full text-sm leading-6"
class="flex-1 pt-6 px-8 w-full text-sm leading-8 text-center"
v-html="authorData.description"
/>
<p
Expand Down
14 changes: 8 additions & 6 deletions src/components/Sidebar/src/TagBox.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<Sticky
:stickyTop="32"
:stickyTop="32 + 81"
endingElId="footer-link"
dynamicElClass="#sticky-tag-box"
>
Expand All @@ -22,8 +22,10 @@
<SvgIcon
class="font-bold"
icon-class="more"
height="2rem"
width="2rem"
fill="currentColor"
stroke="none"
height="1.5rem"
width="1.5rem"
/>
<span>{{ t('settings.more-tags') }}</span>
</div>
Expand Down Expand Up @@ -94,19 +96,19 @@ export default defineComponent({
}
.more-btn {
@apply flex flex-col justify-center items-center h-11 cursor-pointer absolute bg-ob-deep-900 rounded-lg w-full shadow-md overflow-hidden;
@apply flex flex-col justify-center items-center h-9 cursor-pointer absolute bg-ob-deep-900 rounded-lg w-full shadow-md overflow-hidden;
bottom: 0;
left: 50%;
transform: translateX(-50%);
svg {
transition: 0.2s all ease-in-out;
}
span {
@apply opacity-0 font-bold -mb-8;
@apply opacity-0 font-bold -mb-7;
transition: 0.2s all ease-in-out;
}
&:hover span {
@apply scale-110 opacity-100 mb-1.5;
@apply scale-110 opacity-100 mb-0.5;
}
&:hover svg {
@apply opacity-0;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/src/Toc.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<Sticky
:stickyTop="32"
:stickyTop="32 + 81"
endingElId="footer-link"
dynamicElClass="#sticky-sidebar"
>
Expand Down
12 changes: 3 additions & 9 deletions src/components/Title/src/SubTitle.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
<template>
<p
class="
relative
flex
items-center
pb-2
mb-4
text-xl text-ob-bright
uppercase
"
class="relative flex items-center pb-2 mb-4 text-xl text-ob-bright uppercase"
>
<SvgIcon
v-if="icon && side === 'left'"
:icon-class="icon"
class="inline-block mr-2"
fill="none"
stroke="currentColor"
/>
<span :class="titleClass">{{ t(titleStr) }}</span>
<SvgIcon
Expand Down
8 changes: 7 additions & 1 deletion src/components/Title/src/Title.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<template>
<p :id="id" :class="titleClasses">
<SvgIcon v-if="icon" :icon-class="icon" class="inline-block mr-2" />
<SvgIcon
v-if="icon"
:icon-class="icon"
class="inline-block mr-2"
fill="none"
stroke="currentColor"
/>
{{ t(titleStr) }} <span class="ml-2" v-if="count">({{ count }})</span>
<span
class="absolute bottom-0 h-1 w-24 rounded-full"
Expand Down
7 changes: 6 additions & 1 deletion src/hooks/usePageTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export default function usePageTitle() {
metaStore.setTitle(pageTitle.value)
}

const updateTitleByText = (text: string) => {
metaStore.setTitle(text)
}

watch(
() => appStore.locale,
value => {
Expand All @@ -32,6 +36,7 @@ export default function usePageTitle() {

return {
pageTitle,
updateTitle
updateTitle,
updateTitleByText
}
}
2 changes: 2 additions & 0 deletions src/models/ThemeConfig.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ export class CustomSocials {
export class Site {
/** Website subtitle (used after `-`) */
subtitle = ''
/** Slog use in the title */
slogan = ''
/** Author of the blog website */
author = ''
/** Author's nick name */
Expand Down
7 changes: 6 additions & 1 deletion src/stores/meta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineStore } from 'pinia'
import i18n from '@/locales/index'
import { useAppStore } from './app'
import { useRoute } from 'vue-router'

interface StateData {
title: string
Expand Down Expand Up @@ -33,7 +34,11 @@ export const useMetaStore = defineStore({
*/
getTitle(): string {
const appStore = useAppStore()
const subtitle = appStore.themeConfig.site.subtitle || 'Blog'
const route = useRoute()
let subtitle = appStore.themeConfig.site.subtitle || 'Blog'
if (route.name && route.name === 'home') {
subtitle = appStore.themeConfig.site.slogan
}
if (this.title === '') return subtitle
return `${this.title} | ${subtitle}`
}
Expand Down
Loading

0 comments on commit 9c09e57

Please sign in to comment.