mirror of
https://github.com/fmhy/edit.git
synced 2025-07-31 08:12:23 +10:00
l
This commit is contained in:
parent
b1da9e7563
commit
887ad08707
8 changed files with 162 additions and 95 deletions
|
@ -10,18 +10,18 @@ function treatAsHtml(filename: string): boolean {
|
|||
(import.meta as any).env?.VITE_EXTRA_EXTENSIONS ||
|
||||
''
|
||||
|
||||
// md, html? are intentionally omitted
|
||||
; (
|
||||
'3g2,3gp,aac,ai,apng,au,avif,bin,bmp,cer,class,conf,crl,css,csv,dll,' +
|
||||
'doc,eps,epub,exe,gif,gz,ics,ief,jar,jpe,jpeg,jpg,js,json,jsonld,m4a,' +
|
||||
'man,mid,midi,mjs,mov,mp2,mp3,mp4,mpe,mpeg,mpg,mpp,oga,ogg,ogv,ogx,' +
|
||||
'opus,otf,p10,p7c,p7m,p7s,pdf,png,ps,qt,roff,rtf,rtx,ser,svg,t,tif,' +
|
||||
'tiff,tr,ts,tsv,ttf,txt,vtt,wav,weba,webm,webp,woff,woff2,xhtml,xml,' +
|
||||
'yaml,yml,zip' +
|
||||
(extraExts && typeof extraExts === 'string' ? ',' + extraExts : '')
|
||||
)
|
||||
.split(',')
|
||||
.forEach((ext) => KNOWN_EXTENSIONS.add(ext))
|
||||
// md, html? are intentionally omitted
|
||||
;(
|
||||
'3g2,3gp,aac,ai,apng,au,avif,bin,bmp,cer,class,conf,crl,css,csv,dll,' +
|
||||
'doc,eps,epub,exe,gif,gz,ics,ief,jar,jpe,jpeg,jpg,js,json,jsonld,m4a,' +
|
||||
'man,mid,midi,mjs,mov,mp2,mp3,mp4,mpe,mpeg,mpg,mpp,oga,ogg,ogv,ogx,' +
|
||||
'opus,otf,p10,p7c,p7m,p7s,pdf,png,ps,qt,roff,rtf,rtx,ser,svg,t,tif,' +
|
||||
'tiff,tr,ts,tsv,ttf,txt,vtt,wav,weba,webm,webp,woff,woff2,xhtml,xml,' +
|
||||
'yaml,yml,zip' +
|
||||
(extraExts && typeof extraExts === 'string' ? ',' + extraExts : '')
|
||||
)
|
||||
.split(',')
|
||||
.forEach((ext) => KNOWN_EXTENSIONS.add(ext))
|
||||
}
|
||||
|
||||
const ext = filename.split('.').pop()
|
||||
|
@ -51,12 +51,12 @@ function normalizeLink(url: string): string {
|
|||
pathname.endsWith('/') || pathname.endsWith('.html')
|
||||
? url
|
||||
: url.replace(
|
||||
/(?:(^\.+)\/)?.*$/,
|
||||
`$1${pathname.replace(
|
||||
/(\.md)?$/,
|
||||
site.value.cleanUrls ? '' : '.html'
|
||||
)}${search}${hash}`
|
||||
)
|
||||
/(?:(^\.+)\/)?.*$/,
|
||||
`$1${pathname.replace(
|
||||
/(\.md)?$/,
|
||||
site.value.cleanUrls ? '' : '.html'
|
||||
)}${search}${hash}`
|
||||
)
|
||||
|
||||
return withBase(normalizedPath)
|
||||
}
|
||||
|
@ -134,14 +134,22 @@ const processedItems = computed(() => {
|
|||
<template>
|
||||
<div v-if="theme === 'brand'" class="VPButtonDropdown" ref="dropdownRef">
|
||||
<div class="VPButtonWrapper">
|
||||
<component :is="component" class="VPButton VPButtonMain" :class="[size, theme]"
|
||||
:href="href ? normalizeLink(href) : undefined" :target="props.target ?? (isExternal ? '_blank' : undefined)"
|
||||
:rel="props.rel ?? (isExternal ? 'noreferrer' : undefined)">
|
||||
<component
|
||||
:is="component"
|
||||
class="VPButton VPButtonMain"
|
||||
:class="[size, theme]"
|
||||
:href="href ? normalizeLink(href) : undefined"
|
||||
:target="props.target ?? (isExternal ? '_blank' : undefined)"
|
||||
:rel="props.rel ?? (isExternal ? 'noreferrer' : undefined)"
|
||||
>
|
||||
<slot>{{ text }}</slot>
|
||||
</component>
|
||||
<button
|
||||
class="bg-$vp-c-default-soft text-text border-$vp-c-default-soft hover:bg-$vp-c-default-hover active:bg-$vp-c-default-active inline-flex items-center justify-center whitespace-nowrap rounded-md border-2 border-solid px-2.5 py-5 text-md font-medium sm:h-7 VPButtonTrigger"
|
||||
@click="toggleDropdown" :aria-expanded="isDropdownOpen" aria-label="Toggle dropdown menu">
|
||||
@click="toggleDropdown"
|
||||
:aria-expanded="isDropdownOpen"
|
||||
aria-label="Toggle dropdown menu"
|
||||
>
|
||||
<span class="i-lucide:menu"></span>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -151,12 +159,22 @@ const processedItems = computed(() => {
|
|||
<template v-for="item in processedItems" :key="item.text">
|
||||
<div v-if="'items' in item" class="VPButtonDropdownSection">
|
||||
<div class="VPButtonDropdownSectionTitle" v-html="item.text"></div>
|
||||
<a v-for="subItem in item.items" :key="subItem.text" :href="subItem.link" class="VPButtonDropdownItem"
|
||||
@click="closeDropdown">
|
||||
<a
|
||||
v-for="subItem in item.items"
|
||||
:key="subItem.text"
|
||||
:href="subItem.link"
|
||||
class="VPButtonDropdownItem"
|
||||
@click="closeDropdown"
|
||||
>
|
||||
<span v-html="subItem.displayText"></span>
|
||||
</a>
|
||||
</div>
|
||||
<a v-else :href="item.link" class="VPButtonDropdownItem" @click="closeDropdown">
|
||||
<a
|
||||
v-else
|
||||
:href="item.link"
|
||||
class="VPButtonDropdownItem"
|
||||
@click="closeDropdown"
|
||||
>
|
||||
<span v-html="item.displayText"></span>
|
||||
</a>
|
||||
</template>
|
||||
|
@ -164,9 +182,15 @@ const processedItems = computed(() => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<component v-else :is="component" class="VPButton" :class="[size, theme]"
|
||||
:href="href ? normalizeLink(href) : undefined" :target="props.target ?? (isExternal ? '_blank' : undefined)"
|
||||
:rel="props.rel ?? (isExternal ? 'noreferrer' : undefined)">
|
||||
<component
|
||||
v-else
|
||||
:is="component"
|
||||
class="VPButton"
|
||||
:class="[size, theme]"
|
||||
:href="href ? normalizeLink(href) : undefined"
|
||||
:target="props.target ?? (isExternal ? '_blank' : undefined)"
|
||||
:rel="props.rel ?? (isExternal ? 'noreferrer' : undefined)"
|
||||
>
|
||||
<slot>{{ text }}</slot>
|
||||
</component>
|
||||
</template>
|
||||
|
@ -178,11 +202,17 @@ const processedItems = computed(() => {
|
|||
text-align: center;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
transition: color 0.25s, border-color 0.25s, background-color 0.25s;
|
||||
transition:
|
||||
color 0.25s,
|
||||
border-color 0.25s,
|
||||
background-color 0.25s;
|
||||
}
|
||||
|
||||
.VPButton:active {
|
||||
transition: color 0.1s, border-color 0.1s, background-color 0.1s;
|
||||
transition:
|
||||
color 0.1s,
|
||||
border-color 0.1s,
|
||||
background-color 0.1s;
|
||||
}
|
||||
|
||||
.VPButton.medium {
|
||||
|
@ -282,7 +312,9 @@ const processedItems = computed(() => {
|
|||
background-color: var(--vp-c-bg-elv);
|
||||
border: 1px solid var(--vp-c-divider);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||
box-shadow:
|
||||
0 12px 32px rgba(0, 0, 0, 0.1),
|
||||
0 2px 6px rgba(0, 0, 0, 0.08);
|
||||
min-width: 280px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
|
@ -332,14 +364,14 @@ const processedItems = computed(() => {
|
|||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.VPButtonDropdownItem span :deep([class*="i-"]) {
|
||||
.VPButtonDropdownItem span :deep([class*='i-']) {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex-shrink: 0;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.VPButtonDropdownSectionTitle :deep([class*="i-"]) {
|
||||
.VPButtonDropdownSectionTitle :deep([class*='i-']) {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
flex-shrink: 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue