Skip to content

Commit

Permalink
fix: on demand sub path for date-fns & not default load fuse
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed Nov 27, 2024
1 parent f18df81 commit 491ce4e
Show file tree
Hide file tree
Showing 23 changed files with 1,827 additions and 1,286 deletions.
2 changes: 1 addition & 1 deletion demo/custom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"valaxy-theme-custom": "workspace:*"
},
"devDependencies": {
"typescript": "^5.6.3"
"typescript": "^5.7.2"
}
}
4 changes: 2 additions & 2 deletions demo/custom/valaxy-theme-custom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "valaxy-theme-custom",
"version": "0.0.0",
"private": true,
"packageManager": "pnpm@9.13.2",
"packageManager": "pnpm@9.14.2",
"author": {
"email": "me@yunyoujun.cn",
"name": "YunYouJun",
Expand All @@ -23,6 +23,6 @@
"types": "types/index.d.ts",
"dependencies": {
"@iconify-json/ant-design": "^1.2.2",
"@iconify-json/simple-icons": "^1.2.11"
"@iconify-json/simple-icons": "^1.2.13"
}
}
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
},
"devDependencies": {
"@iconify-json/carbon": "^1.2.4",
"@iconify-json/simple-icons": "^1.2.11",
"@iconify-json/simple-icons": "^1.2.13",
"nodemon": "^3.1.7",
"vite": "^5.4.11",
"vite": "^6.0.0",
"vitepress": "1.1.4"
}
}
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"version": "0.20.4",
"private": true,
"packageManager": "pnpm@9.13.2",
"packageManager": "pnpm@9.14.2",
"description": "📄 Vite & Vue powered static blog generator.",
"author": {
"email": "me@yunyoujun.cn",
Expand Down Expand Up @@ -82,21 +82,21 @@
"@antfu/eslint-config": "2.17.0",
"@iconify-json/logos": "^1.2.3",
"@iconify-json/vscode-icons": "^1.2.2",
"@microsoft/api-extractor": "^7.47.11",
"@playwright/test": "^1.48.2",
"@microsoft/api-extractor": "^7.48.0",
"@playwright/test": "^1.49.0",
"@types/debug": "^4.1.12",
"@types/markdown-it-attrs": "^4.1.3",
"@types/markdown-it-container": "^2.0.10",
"@types/markdown-it-emoji": "^3.0.1",
"@types/node": "^22.9.0",
"@types/node": "^22.10.0",
"@types/prompts": "^2.4.9",
"@types/resolve": "^1.20.6",
"bumpp": "^9.8.1",
"cross-env": "^7.0.3",
"decap-cms-app": "^3.4.0",
"eslint": "^9.15.0",
"https-localhost": "^4.7.1",
"husky": "^9.1.6",
"husky": "^9.1.7",
"lint-staged": "^15.2.10",
"npm-run-all": "^4.1.5",
"prompts": "^2.4.2",
Expand All @@ -106,9 +106,9 @@
"stylelint-config-standard-scss": "^13.1.0",
"tsup": "^8.3.5",
"tsx": "^4.19.2",
"typescript": "^5.6.3",
"typescript": "^5.7.2",
"unbuild": "^2.0.0",
"vitest": "^2.1.5",
"vitest": "^2.1.6",
"vue-tsc": "2.0.17",
"zx": "^8.2.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/create-valaxy/template-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"valaxy-theme-yun": "0.20.4"
},
"devDependencies": {
"typescript": "^5.6.3"
"typescript": "^5.7.2"
}
}
8 changes: 4 additions & 4 deletions packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
},
"dependencies": {
"@rollup/pluginutils": "^5.1.3",
"axios": "^1.7.7",
"body-parser": "^1.20.3",
"axios": "^1.7.8",
"body-parser": "^2.0.1",
"http-proxy-middleware": "^3.0.3",
"js-yaml": "^4.1.0",
"picocolors": "^1.1.1",
Expand All @@ -43,9 +43,9 @@
"@types/splitpanes": "^2.2.6",
"gray-matter": "^4.0.3",
"splitpanes": "^3.1.5",
"typescript": "^5.6.3",
"typescript": "^5.7.2",
"unbuild": "^2.0.0",
"unplugin-vue-router": "^0.10.8",
"vite": "^5.4.11"
"vite": "^6.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/valaxy-addon-components/components/VCLiveTime.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { differenceInSeconds } from 'date-fns'
import { differenceInSeconds } from 'date-fns/differenceInSeconds'
const props = defineProps<{
startTime: string
Expand Down
2 changes: 1 addition & 1 deletion packages/valaxy-addon-lightgallery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"valaxy": "latest"
},
"dependencies": {
"lightgallery": "^2.7.2"
"lightgallery": "2.7.2"
}
}
2 changes: 1 addition & 1 deletion packages/valaxy-addon-waline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"valaxy": "latest"
},
"dependencies": {
"@waline/client": "^3.3.2"
"@waline/client": "^3.4.0"
}
}
11 changes: 8 additions & 3 deletions packages/valaxy-theme-yun/components/YunFuseSearch.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useFuseSearch } from 'valaxy'
import { isClient, onClickOutside, useScrollLock } from '@vueuse/core'
defineProps<{
const props = defineProps<{
open: boolean
}>()
const emit = defineEmits(['close'])
Expand All @@ -14,14 +14,19 @@ const input = ref('')
const isLocked = useScrollLock(isClient ? document.documentElement : null)
const { t } = useI18n()
const { results } = useFuseSearch(input)
const { results, fetchFuseListData } = useFuseSearch(input)
const searchInputRef = ref<HTMLInputElement>()
const searchContainer = ref<HTMLElement>()
onClickOutside(searchInputRef, () => {
// emit('close')
})
watch(() => props.open, () => {
if (props.open)
fetchFuseListData()
})
</script>

<template>
Expand Down
3 changes: 2 additions & 1 deletion packages/valaxy-theme-yun/components/YunMdTimeWarning.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { computed, ref, watch } from 'vue'
import { useFrontmatter } from 'valaxy'
import { useI18n } from 'vue-i18n'
import { differenceInMilliseconds, formatDistanceToNow } from 'date-fns'
import { differenceInMilliseconds } from 'date-fns/differenceInMilliseconds'
import { formatDistanceToNow } from 'date-fns/formatDistanceToNow'
const fm = useFrontmatter()
const { t, locale } = useI18n()
Expand Down
2 changes: 1 addition & 1 deletion packages/valaxy-theme-yun/layouts/post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useFrontmatter, useFullUrl, useSiteConfig } from 'valaxy'
import type { Article } from '@unhead/schema-org'
import { defineArticle, useSchemaOrg } from '@unhead/schema-org'
import { toDate } from 'date-fns'
import { toDate } from 'date-fns/toDate'
const siteConfig = useSiteConfig()
const frontmatter = useFrontmatter()
Expand Down
6 changes: 3 additions & 3 deletions packages/valaxy-theme-yun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"@ctrl/tinycolor": "^4.1.0",
"@explosions/fireworks": "^0.1.0",
"@iconify-json/ant-design": "^1.2.2",
"@iconify-json/simple-icons": "^1.2.11",
"@iconify-json/simple-icons": "^1.2.13",
"@vueuse/motion": "^2.2.6",
"animejs": "^3.2.2",
"gsap": "^3.12.5",
"primevue": "^4.2.2",
"radix-vue": "^1.9.9"
"primevue": "^4.2.3",
"radix-vue": "^1.9.10"
},
"devDependencies": {
"@types/animejs": "^3.1.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/valaxy/client/composables/locale.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isClient, useStorage } from '@vueuse/core'
import { useI18n } from 'vue-i18n'
import { setDefaultOptions } from 'date-fns'
import { setDefaultOptions } from 'date-fns/setDefaultOptions'
import { enUS, zhCN } from 'date-fns/locale'

export function useLocale() {
Expand Down
2 changes: 1 addition & 1 deletion packages/valaxy/client/composables/search/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './fuse'
export * from './useFuseSearch'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, onMounted, shallowRef } from 'vue'
import { computed, shallowRef } from 'vue'
import { useSiteConfig } from 'valaxy'
import type { MaybeRefOrGetter } from '@vueuse/shared'
import type { UseFuseOptions } from '@vueuse/integrations/useFuse'
Expand Down Expand Up @@ -31,12 +31,13 @@ export function useFuseSearch<T extends FuseListItem = FuseListItem>(
// resultLimit: resultLimit.value,
// matchAllWhenSearchEmpty: matchAllWhenSearchEmpty.value,
}

const useFuseOptions = computed<UseFuseOptions<T>>(() => ({
...defaultOptions,
...options,
}))

const ruse = useFuse<T>(search, fuseListData, useFuseOptions)
const { fuse, results } = useFuse<T>(search, fuseListData, useFuseOptions)

async function fetchFuseListData(path?: string) {
const fuseListDataPath = path
Expand All @@ -51,7 +52,10 @@ export function useFuseSearch<T extends FuseListItem = FuseListItem>(
fuseListData.value = data
}

onMounted(fetchFuseListData)
return {
fuse,
results,

return ruse
fetchFuseListData,
}
}
3 changes: 2 additions & 1 deletion packages/valaxy/client/utils/time.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ToDateOptionsWithTZ } from 'date-fns-tz'
import { format as formatWithTZ, toZonedTime } from 'date-fns-tz'
import { format, toDate } from 'date-fns'
import { format } from 'date-fns/format'
import { toDate } from 'date-fns/toDate'
import { DateTime } from 'luxon'
import type { Post } from '../../types'
import { i18n } from '../modules/valaxy'
Expand Down
4 changes: 2 additions & 2 deletions packages/valaxy/node/cli/utils/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { render } from 'ejs'
import { ensureSuffix } from '@antfu/utils'
import { consola } from 'consola'
import { green, magenta } from 'picocolors'
import { format } from 'date-fns'
import { formatDate } from 'date-fns/format'
import { exists } from './fs'
import { getTemplate } from './scaffold'
import { defaultPostTemplate, userRoot } from './constants'
Expand Down Expand Up @@ -67,5 +67,5 @@ async function genLayoutTemplate({

// 24h format
const dateFormat = 'yyyy-MM-dd HH:mm:ss'
return render(template, { title, layout, date: date ? format(new Date(), dateFormat) : '' })
return render(template, { title, layout, date: date ? formatDate(new Date(), dateFormat) : '' })
}
2 changes: 1 addition & 1 deletion packages/valaxy/node/modules/rss/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import consola from 'consola'
import { colors } from 'consola/utils'

import { getBorderCharacters, table } from 'table'
import { formatDate } from 'date-fns'
import { formatDate } from 'date-fns/format'
import ora from 'ora'

import { getCreatedTime, getUpdatedTime } from '../../utils/date'
Expand Down
1 change: 0 additions & 1 deletion packages/valaxy/node/plugins/extendConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const EXCLUDE = [
'vue',
// 'vue-i18n',
'vue-router',
'vue-demi',
'@vue/devtools-api',

// addon, todo add externals for addon
Expand Down
22 changes: 11 additions & 11 deletions packages/valaxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@
"dependencies": {
"@antfu/install-pkg": "^0.4.1",
"@antfu/utils": "^0.7.10",
"@clack/prompts": "^0.8.1",
"@clack/prompts": "^0.8.2",
"@iconify-json/ri": "^1.2.3",
"@intlify/unplugin-vue-i18n": "4",
"@types/katex": "^0.16.7",
"@types/luxon": "^3.4.2",
"@unhead/addons": "^1.11.11",
"@unhead/schema-org": "^1.11.11",
"@unhead/vue": "^1.11.11",
"@unhead/addons": "^1.11.13",
"@unhead/schema-org": "^1.11.13",
"@unhead/vue": "^1.11.13",
"@valaxyjs/devtools": "workspace:*",
"@valaxyjs/utils": "workspace:*",
"@vitejs/plugin-vue": "^5.2.0",
"@vitejs/plugin-vue": "^5.2.1",
"@vue/devtools-api": "^7.6.4",
"@vueuse/core": "^11.2.0",
"@vueuse/integrations": "^11.2.0",
"@vueuse/core": "12.0.0-beta.1",
"@vueuse/integrations": "12.0.0-beta.1",
"consola": "^3.2.3",
"critters": "^0.0.25",
"cross-spawn": "^7.0.5",
"cross-spawn": "^7.0.6",
"css-i18n": "^0.0.5",
"date-fns": "^4.1.0",
"date-fns-tz": "^3.2.0",
Expand Down Expand Up @@ -122,21 +122,21 @@
"qrcode": "^1.5.4",
"resolve-global": "^2.0.0",
"sass": "^1.81.0",
"shiki": "^1.23.0",
"shiki": "^1.23.1",
"star-markdown-css": "^0.5.3",
"unocss": "^0.64.1",
"unplugin-vue-components": "^0.27.4",
"unplugin-vue-markdown": "^0.26.2",
"unplugin-vue-router": "^0.10.8",
"vanilla-lazyload": "^19.1.3",
"vite": "^5.4.11",
"vite": "^6.0.0",
"vite-plugin-vue-devtools": "^7.6.4",
"vite-plugin-vue-layouts": "^0.11.0",
"vite-ssg": "^0.24.1",
"vite-ssg-sitemap": "^0.8.1",
"vue": "^3.5.13",
"vue-i18n": "^10.0.4",
"vue-router": "^4.4.5",
"vue-router": "^4.5.0",
"yargs": "^17.7.2"
},
"devDependencies": {
Expand Down
Loading

1 comment on commit 491ce4e

@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://674683fb2cc71f4f1ca518af--valaxy.netlify.app

Please sign in to comment.