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. // URL for the sponsor page for the member.
sponsor?: string sponsor?: string
// Text for the sponsor link. Defaults to 'Sponsor'.
actionText?: string
} }
``` ```

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

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

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

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

@ -8,6 +8,7 @@ import { rimraf } from 'rimraf'
import { pathToFileURL } from 'url' import { pathToFileURL } from 'url'
import type { BuildOptions, Rollup } from 'vite' import type { BuildOptions, Rollup } from 'vite'
import { resolveConfig, type SiteConfig } from '../config' import { resolveConfig, type SiteConfig } from '../config'
import { clearCache } from '../markdownToVue'
import { slash, type HeadConfig } from '../shared' import { slash, type HeadConfig } from '../shared'
import { deserializeFunctions, serializeFunctions } from '../utils/fnSerialize' import { deserializeFunctions, serializeFunctions } from '../utils/fnSerialize'
import { task } from '../utils/task' import { task } from '../utils/task'
@ -140,6 +141,7 @@ export async function build(
await generateSitemap(siteConfig) await generateSitemap(siteConfig)
await siteConfig.buildEnd?.(siteConfig) await siteConfig.buildEnd?.(siteConfig)
clearCache()
siteConfig.logger.info( siteConfig.logger.info(
`build complete in ${((Date.now() - start) / 1000).toFixed(2)}s.` `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) const templateString = createTitleTemplate(siteData.title, template)
if (title === templateString.slice(3)) {
return title
}
return `${title}${templateString}` return `${title}${templateString}`
} }

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

Loading…
Cancel
Save