Merge branch 'vuejs:main' into refactor/local-search

pull/3374/head
Yuxuan Zhang 2 years ago committed by GitHub
commit b1914a7593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -212,6 +212,9 @@ interface TeamMember {
// URL for the sponsor page for the member.
sponsor?: string
// Text for the sponsor link. Defaults to 'Sponsor'.
actionText?: string
}
```

@ -4,7 +4,6 @@ import {
computedAsync,
debouncedWatch,
onKeyStroke,
reactify,
useEventListener,
useLocalStorage,
useScrollLock,
@ -23,7 +22,6 @@ import {
onMounted,
ref,
shallowRef,
toRef,
watch,
watchEffect,
type Ref
@ -32,7 +30,7 @@ import type { ModalTranslations } from '../../../../types/local-search'
import { pathToFile } from '../../app/utils'
import { useData } from '../composables/data'
import { LRUCache } from '../support/lru'
import { createTranslate } from '../support/translation'
import { createSearchTranslate } from '../support/translation'
const emit = defineEmits<{
(e: 'close'): void
@ -361,10 +359,7 @@ const defaultTranslations: { modal: ModalTranslations } = {
}
}
const $t = reactify(createTranslate)(
toRef(() => theme.value.search?.options),
defaultTranslations
)
const $t = createSearchTranslate(defaultTranslations)
// Back

@ -1,11 +1,6 @@
<script lang="ts" setup>
import { reactify } from '@vueuse/core'
import { toRef } from 'vue'
import type { ButtonTranslations } from '../../../../types/local-search'
import { useData } from '../composables/data'
import { createTranslate } from '../support/translation'
const { theme } = useData()
import { createSearchTranslate } from '../support/translation'
// Button-Translations
const defaultTranslations: { button: ButtonTranslations } = {
@ -15,10 +10,7 @@ const defaultTranslations: { button: ButtonTranslations } = {
}
}
const $t = reactify(createTranslate)(
toRef(() => theme.value.search?.options),
defaultTranslations
)
const $t = createSearchTranslate(defaultTranslations)
</script>
<template>

@ -47,7 +47,7 @@ withDefaults(defineProps<Props>(), {
</div>
<div v-if="member.sponsor" class="sp">
<VPLink class="sp-link" :href="member.sponsor" no-icon>
<VPIconHeart class="sp-icon" /> Sponsor
<VPIconHeart class="sp-icon" /> {{ member.actionText || 'Sponsor' }}
</VPLink>
</div>
</article>

@ -3,14 +3,14 @@ import { useData } from '../composables/data'
/**
* @param themeObject Can be an object with `translations` and `locales` properties
*/
export function createTranslate(
themeObject: any,
export function createSearchTranslate(
defaultTranslations: Record<string, any>
): (key: string) => string {
const { localeIndex } = useData()
const { localeIndex, theme } = useData()
function translate(key: string): string {
const keyPath = key.split('.')
const themeObject = theme.value.search?.options
const isObject = themeObject && typeof themeObject === 'object'
const locales =

@ -8,6 +8,7 @@ import { rimraf } from 'rimraf'
import { pathToFileURL } from 'url'
import type { BuildOptions, Rollup } from 'vite'
import { resolveConfig, type SiteConfig } from '../config'
import { clearCache } from '../markdownToVue'
import { slash, type HeadConfig } from '../shared'
import { deserializeFunctions, serializeFunctions } from '../utils/fnSerialize'
import { task } from '../utils/task'
@ -140,6 +141,7 @@ export async function build(
await generateSitemap(siteConfig)
await siteConfig.buildEnd?.(siteConfig)
clearCache()
siteConfig.logger.info(
`build complete in ${((Date.now() - start) / 1000).toFixed(2)}s.`

@ -113,6 +113,10 @@ export function createTitle(siteData: SiteData, pageData: PageData): string {
const templateString = createTitleTemplate(siteData.title, template)
if (title === templateString.slice(3)) {
return title
}
return `${title}${templateString}`
}

@ -348,6 +348,7 @@ export namespace DefaultTheme {
desc?: string
links?: SocialLink[]
sponsor?: string
actionText?: string
}
// outline -------------------------------------------------------------------

Loading…
Cancel
Save