Skip to content

Commit

Permalink
perf: upgrade to use vite-plugin-page for better page setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Sep 3, 2023
1 parent 2e4c3e5 commit a51eb6e
Show file tree
Hide file tree
Showing 24 changed files with 214 additions and 101 deletions.
2 changes: 1 addition & 1 deletion layout/index.ejs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><script type="module" crossorigin src="/static/js/index_prod-00ee5e98.js"></script><link rel="stylesheet" href="/static/css/index_prod-7b0ddf03.css"></head><body id="body-container"><noscript><strong>We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><script type="module" crossorigin src="/static/js/34662c9c.js"></script><link rel="stylesheet" href="/static/css/0f00c169.css"></head><body id="body-container"><noscript><strong>We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"typescript": "~5.1.5",
"vite": "^4.3.9",
"vite-plugin-html-transformer": "^4.0.0",
"vite-plugin-pages": "^0.31.0",
"vite-plugin-svg-icons": "^2.0.1",
"vue-easy-lightbox": "^1.16.0",
"vue-jest": "^3.0.7",
Expand Down
155 changes: 155 additions & 0 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/ArticleCard/src/Article.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

<router-link
v-if="post.title"
:to="{ name: 'post', params: { slug: post.slug } }"
:to="{ name: 'post-slug', params: { slug: post.slug } }"
>
<h1 data-dia="article-link">{{ post.title }}</h1>
</router-link>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ArticleCard/src/HorizontalArticle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

<router-link
v-if="post.title"
:to="{ name: 'post', params: { slug: post.slug } }"
:to="{ name: 'post-slug', params: { slug: post.slug } }"
>
<h1 data-dia="article-link">{{ post.title }}</h1>
</router-link>
Expand Down
8 changes: 4 additions & 4 deletions src/components/SearchModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export default defineComponent({
reloadRecentResult()
handleStatusChange(false)
if (result.slug !== '')
router.push({ name: 'post', params: { slug: result.slug } })
router.push({ name: 'post-slug', params: { slug: result.slug } })
}
const handleResetInput = () => {
Expand Down Expand Up @@ -469,9 +469,9 @@ export default defineComponent({
const initSearch = async () => {
searchIndexStatus.value = false
isEmpty.value = false
await searchStore.fetchSearchIndex().then(() => {
searchIndexStatus.value = true
})
// await searchStore.fetchSearchIndex().then(() => {
// searchIndexStatus.value = true
// })
}
onBeforeMount(initSearch)
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/usePageTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ export default function usePageTitle() {

const updateTitle = (locale?: Locales | undefined) => {
const currentLocale: Locales = locale ?? appStore.locale
const menuName = String(route.name)
const menuName = String(route.name === 'index' ? 'home' : route.name)
const routeInfo =
appStore.themeConfig.menu.menus[
menuName.charAt(0).toUpperCase() + menuName.slice(1)
]
pageTitle.value =
(routeInfo.i18n && routeInfo.i18n[currentLocale]) || routeInfo.name
(routeInfo && routeInfo.i18n && routeInfo.i18n[currentLocale]) ||
routeInfo.name
metaStore.setTitle(pageTitle.value)
}

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion src/views/Archives.vue → src/pages/archives.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
</div>
<div class="timeline-marker"></div>
<div class="timeline-content">
<router-link :to="{ name: 'post', params: { slug: post.slug } }">
<router-link
:to="{ name: 'post-slug', params: { slug: post.slug } }"
>
<h3 class="timeline-title">{{ post.title }}</h3>
</router-link>
<p>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a51eb6e

Please sign in to comment.