This commit is contained in:
taskylizard 2025-06-27 22:16:37 +00:00
parent ecd835f172
commit 15a56af368
No known key found for this signature in database
GPG key ID: 1820131ED1A24120
7 changed files with 408 additions and 364 deletions

View file

@ -9,6 +9,7 @@ import { defineConfig } from 'vitepress'
import { import {
commitRef, commitRef,
feedback, feedback,
wikiSidebar as homepageItems,
meta, meta,
nav, nav,
search, search,
@ -85,6 +86,9 @@ export default defineConfig({
.finally(() => consola.success('Success!')) .finally(() => consola.success('Success!'))
}, },
vite: { vite: {
define: {
FMHY_HOMEPAGE_ITEMS: JSON.stringify(homepageItems)
},
ssr: { ssr: {
noExternal: ['@fmhy/components'] noExternal: ['@fmhy/components']
}, },

View file

@ -152,7 +152,7 @@ export const nav: DefaultTheme.NavItem[] = [
{ text: '🌐 Search', link: '/posts/search' }, { text: '🌐 Search', link: '/posts/search' },
{ text: '🔖 Bookmarks', link: 'https://github.com/fmhy/bookmarks' }, { text: '🔖 Bookmarks', link: 'https://github.com/fmhy/bookmarks' },
{ text: '✅ SafeGuard', link: 'https://github.com/fmhy/FMHY-SafeGuard' }, { text: '✅ SafeGuard', link: 'https://github.com/fmhy/FMHY-SafeGuard' },
{ text: '🚀 Startpage', link: 'https://fmhy.net/startpage' }, { text: '🚀 Startpage', link: '/startpage' },
{ text: '📋 snowbin', link: 'https://pastes.fmhy.net' }, { text: '📋 snowbin', link: 'https://pastes.fmhy.net' },
{ {
text: '® Redlib', text: '® Redlib',

View file

@ -1,6 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, onUnmounted, ref } from 'vue' import { computed, onMounted, onUnmounted, ref } from 'vue'
import { wikiSidebar as homepageItems } from '../../constants'
const KNOWN_EXTENSIONS = new Set() const KNOWN_EXTENSIONS = new Set()
@ -11,18 +10,18 @@ function treatAsHtml(filename: string): boolean {
(import.meta as any).env?.VITE_EXTRA_EXTENSIONS || (import.meta as any).env?.VITE_EXTRA_EXTENSIONS ||
'' ''
// md, html? are intentionally omitted // md, html? are intentionally omitted
;( ; (
'3g2,3gp,aac,ai,apng,au,avif,bin,bmp,cer,class,conf,crl,css,csv,dll,' + '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,' + '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,' + '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,' + '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,' + 'tiff,tr,ts,tsv,ttf,txt,vtt,wav,weba,webm,webp,woff,woff2,xhtml,xml,' +
'yaml,yml,zip' + 'yaml,yml,zip' +
(extraExts && typeof extraExts === 'string' ? ',' + extraExts : '') (extraExts && typeof extraExts === 'string' ? ',' + extraExts : '')
) )
.split(',') .split(',')
.forEach((ext) => KNOWN_EXTENSIONS.add(ext)) .forEach((ext) => KNOWN_EXTENSIONS.add(ext))
} }
const ext = filename.split('.').pop() const ext = filename.split('.').pop()
@ -52,12 +51,12 @@ function normalizeLink(url: string): string {
pathname.endsWith('/') || pathname.endsWith('.html') pathname.endsWith('/') || pathname.endsWith('.html')
? url ? url
: url.replace( : url.replace(
/(?:(^\.+)\/)?.*$/, /(?:(^\.+)\/)?.*$/,
`$1${pathname.replace( `$1${pathname.replace(
/(\.md)?$/, /(\.md)?$/,
site.value.cleanUrls ? '' : '.html' site.value.cleanUrls ? '' : '.html'
)}${search}${hash}` )}${search}${hash}`
) )
return withBase(normalizedPath) return withBase(normalizedPath)
} }
@ -114,7 +113,7 @@ onUnmounted(() => {
}) })
const processedItems = computed(() => { const processedItems = computed(() => {
return homepageItems.map((item: any) => { return FMHY_HOMEPAGE_ITEMS.map((item: any) => {
if ('items' in item && item.items) { if ('items' in item && item.items) {
return { return {
...item, ...item,
@ -135,26 +134,15 @@ const processedItems = computed(() => {
<template> <template>
<div v-if="theme === 'brand'" class="VPButtonDropdown" ref="dropdownRef"> <div v-if="theme === 'brand'" class="VPButtonDropdown" ref="dropdownRef">
<div class="VPButtonWrapper"> <div class="VPButtonWrapper">
<component <component :is="component" class="VPButton VPButtonMain" :class="[size, theme]"
:is="component" :href="href ? normalizeLink(href) : undefined" :target="props.target ?? (isExternal ? '_blank' : undefined)"
class="VPButton VPButtonMain" :rel="props.rel ?? (isExternal ? 'noreferrer' : undefined)">
:class="[size, theme]"
:href="href ? normalizeLink(href) : undefined"
:target="props.target ?? (isExternal ? '_blank' : undefined)"
:rel="props.rel ?? (isExternal ? 'noreferrer' : undefined)"
>
<slot>{{ text }}</slot> <slot>{{ text }}</slot>
</component> </component>
<button <button
class="bg-$vp-c-default-soft text-text border-$vp-c-default-soft hover:border-primary ml-3 inline-flex h-8 items-center justify-center whitespace-nowrap rounded-md border-2 border-solid px-2.5 py-4.5 text-sm font-medium transition-all duration-300 sm:h-7 VPButtonTrigger" class="bg-$vp-c-default-soft text-text border-$vp-c-default-soft hover:border-primary ml-3 inline-flex h-8 items-center justify-center whitespace-nowrap rounded-md border-2 border-solid px-2.5 py-4.5 text-md font-medium transition-all duration-300 sm:h-7 VPButtonTrigger"
@click="toggleDropdown" @click="toggleDropdown" :aria-expanded="isDropdownOpen" aria-label="Toggle dropdown menu">
:aria-expanded="isDropdownOpen" <span class="i-lucide:menu"></span>
aria-label="Toggle dropdown menu"
>
<span
class="i-lucide:chevron-down"
:class="{ 'rotate-180': isDropdownOpen }"
></span>
</button> </button>
</div> </div>
@ -163,22 +151,12 @@ const processedItems = computed(() => {
<template v-for="item in processedItems" :key="item.text"> <template v-for="item in processedItems" :key="item.text">
<div v-if="'items' in item" class="VPButtonDropdownSection"> <div v-if="'items' in item" class="VPButtonDropdownSection">
<div class="VPButtonDropdownSectionTitle" v-html="item.text"></div> <div class="VPButtonDropdownSectionTitle" v-html="item.text"></div>
<a <a v-for="subItem in item.items" :key="subItem.text" :href="subItem.link" class="VPButtonDropdownItem"
v-for="subItem in item.items" @click="closeDropdown">
:key="subItem.text"
:href="subItem.link"
class="VPButtonDropdownItem"
@click="closeDropdown"
>
<span v-html="subItem.displayText"></span> <span v-html="subItem.displayText"></span>
</a> </a>
</div> </div>
<a <a v-else :href="item.link" class="VPButtonDropdownItem" @click="closeDropdown">
v-else
:href="item.link"
class="VPButtonDropdownItem"
@click="closeDropdown"
>
<span v-html="item.displayText"></span> <span v-html="item.displayText"></span>
</a> </a>
</template> </template>
@ -186,15 +164,9 @@ const processedItems = computed(() => {
</div> </div>
</div> </div>
<component <component v-else :is="component" class="VPButton" :class="[size, theme]"
v-else :href="href ? normalizeLink(href) : undefined" :target="props.target ?? (isExternal ? '_blank' : undefined)"
:is="component" :rel="props.rel ?? (isExternal ? 'noreferrer' : undefined)">
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> <slot>{{ text }}</slot>
</component> </component>
</template> </template>

View file

@ -18,3 +18,5 @@ declare module '*.vue' {
const component: import('vue').Component const component: import('vue').Component
export default component export default component
} }
declare const FMHY_HOMEPAGE_ITEMS: typeof import('./constants').wikiSidebar

View file

@ -26,7 +26,7 @@ hero:
text: Discord text: Discord
link: https://rentry.co/fmhy-invite link: https://rentry.co/fmhy-invite
fatures: features:
- title: Adblocking / Privacy - title: Adblocking / Privacy
link: /adblockvpnguide link: /adblockvpnguide
details: Learn how to block ads, trackers and other nasty things. details: Learn how to block ads, trackers and other nasty things.

View file

@ -34,9 +34,9 @@
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"pathe": "^2.0.1", "pathe": "^2.0.1",
"reka-ui": "^2.3.1", "reka-ui": "^2.3.1",
"unocss": "66.1.0-beta.3", "unocss": "66.3.2",
"vitepress": "^1.6.3", "vitepress": "1.6.3",
"vue": "^3.5.13", "vue": "^3.5.17",
"x-satori": "^0.2.0", "x-satori": "^0.2.0",
"zod": "^3.24.2" "zod": "^3.24.2"
}, },

666
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff