Skip to content

Commit

Permalink
fix: dynamic route build & 404 styles for theme-yun, close #299, #302
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed Dec 17, 2023
1 parent eda4fbc commit fa470be
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
3 changes: 3 additions & 0 deletions demo/yun/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ public/valaxy-fuse-list.json

# valaxy
public/valaxy-fuse-list.json

# valaxy
public/valaxy-fuse-list.json
5 changes: 5 additions & 0 deletions demo/yun/pages/[year]/[month]/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
asd
</div>
</template>
5 changes: 5 additions & 0 deletions demo/yun/pages/[year]/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
asd
</div>
</template>
2 changes: 1 addition & 1 deletion packages/valaxy-theme-yun/components/YunPostList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const displayedPosts = computed(() =>
<template>
<div class="yun-post-list" w="full" p="x-4 lt-sm:0">
<template v-if="!displayedPosts.length">
<div py2 op50>
<div py2 op50 text-center>
博主还什么都没写哦~
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/valaxy-theme-yun/layouts/404.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { back } = useBack()
404
</div>

<RouterView />
<!-- <RouterView /> -->

<div>
<button class="btn rounded-full" p="x-6 y-2" text="sm" m="3 t8" :title="t('button.back')" @click="back">
Expand Down
17 changes: 2 additions & 15 deletions packages/valaxy/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import fs from 'fs-extra'
import consola from 'consola'
import type { ResolvedValaxyOptions } from './options'
import { ViteValaxyPlugins } from './plugins/preset'
import { ALL_ROUTE } from './constants'

// import { logger } from './logger'

export async function build(
options: ResolvedValaxyOptions,
Expand Down Expand Up @@ -38,18 +35,8 @@ export async function ssgBuild(
defaultConfig.ssgOptions = {
script: 'async',
formatting: 'minify',
includedRoutes(paths, routes) {
const excludePages = ['/:..all', ALL_ROUTE]
const postSize = paths.filter(path => path.startsWith('/posts/')).length
const pages = Math.ceil(postSize / options.config.siteConfig.pageSize)
const pagesArr = Array.from({ length: pages }, (_, i) => i + 1)

return routes.filter(r => !excludePages.includes(r.path)).flatMap((route) => {
// /page/:page
return route.path === '/page/:page'
? pagesArr.map(slug => `/page/${slug}`)
: route.path
})
crittersOptions: {
reduceInlineStyles: false,
},
onFinished() {
generateSitemap(
Expand Down

2 comments on commit fa470be

@vercel
Copy link

@vercel vercel bot commented on fa470be Dec 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Published on https://yun.valaxy.site as production
🚀 Deployed on https://657ef68d8ccef372f4963ae6--valaxy.netlify.app

Please sign in to comment.