feat: redesign homepage

This commit is contained in:
taskylizard 2024-08-31 18:17:01 +00:00
parent 76d6ed95cf
commit c8a8f4192e
No known key found for this signature in database
GPG key ID: 1820131ED1A24120
40 changed files with 694 additions and 139 deletions

View file

@ -1,6 +1,8 @@
import consola from 'consola'
import UnoCSS from 'unocss/vite'
import AutoImport from 'unplugin-auto-import/vite'
import OptimizeExclude from 'vite-plugin-optimize-exclude'
import Terminal from 'vite-plugin-terminal'
import { defineConfig } from 'vitepress'
import {
commitRef,
@ -53,8 +55,16 @@ export default defineConfig({
.finally(() => consola.success('Success!'))
},
vite: {
ssr: {
noExternal: ['@fmhy/components']
},
optimizeDeps: { exclude: ['workbox-window'] },
plugins: [
OptimizeExclude(),
Terminal({
console: 'terminal',
output: ['console', 'terminal']
}),
UnoCSS({
configFile: '../unocss.config.ts'
}),
@ -112,7 +122,6 @@ export default defineConfig({
outline: 'deep',
logo: '/fmhy.ico',
nav: [
{ text: '📚 Beginners Guide', link: '/beginners-guide' },
{ text: '🔖 Glossary', link: 'https://rentry.org/The-Piracy-Glossary' },
{ text: '📑 Guides', link: 'https://rentry.co/fmhy-guides' },
{
@ -122,10 +131,8 @@ export default defineConfig({
{
text: '🪅 Ecosystem',
items: [
{ text: '💙 Feedback', link: '/feedback' },
{ text: '🌐 Search', link: '/posts/search' },
{ text: '📰 Posts', link: '/posts' },
{ text: '💬 Feedback', link: '/feedback' },
{ text: '💙 Contribute', link: 'other/contributing' },
{ text: '🏞 Wallpapers', link: '/other/wallpapers' },
{ text: '📋 snowbin', link: 'https://pastes.fmhy.net' },
{ text: '🔍 SearXNG', link: 'https://searx.fmhy.net/' },

View file

@ -28,9 +28,8 @@ export const meta = {
export const commitRef =
process.env.CF_PAGES && process.env.CF_PAGES_COMMIT_SHA
? `<a href="https://github.com/fmhy/FMHYEdit/commit/${
process.env.CF_PAGES_COMMIT_SHA
}">${process.env.CF_PAGES_COMMIT_SHA.slice(0, 8)}</a>`
? `<a href="https://github.com/fmhy/FMHYEdit/commit/${process.env.CF_PAGES_COMMIT_SHA
}">${process.env.CF_PAGES_COMMIT_SHA.slice(0, 8)}</a>`
: 'dev'
export const feedback = `<a href="/feedback" class="feedback-footer">Made with ❤</a>`
@ -120,7 +119,7 @@ export const socialLinks: DefaultTheme.SocialLink[] = [
{
ariaLabel: 'Bluesky',
icon: {
svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Bluesky</title><path fill="#A1A1AA" d="M12 10.8c-1.087-2.114-4.046-6.053-6.798-7.995C2.566.944 1.561 1.266.902 1.565.139 1.908 0 3.08 0 3.768c0 .69.378 5.65.624 6.479.815 2.736 3.713 3.66 6.383 3.364.136-.02.275-.039.415-.056-.138.022-.276.04-.415.056-3.912.58-7.387 2.005-2.83 7.078 5.013 5.19 6.87-1.113 7.823-4.308.953 3.195 2.05 9.271 7.733 4.308 4.267-4.308 1.172-6.498-2.74-7.078a8.741 8.741 0 0 1-.415-.056c.14.017.279.036.415.056 2.67.297 5.568-.628 6.383-3.364.246-.828.624-5.79.624-6.478 0-.69-.139-1.861-.902-2.206-.659-.298-1.664-.62-4.3 1.24C16.046 4.748 13.087 8.687 12 10.8Z"/></svg>'
svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Bluesky</title><path d="M12 10.8c-1.087-2.114-4.046-6.053-6.798-7.995C2.566.944 1.561 1.266.902 1.565.139 1.908 0 3.08 0 3.768c0 .69.378 5.65.624 6.479.815 2.736 3.713 3.66 6.383 3.364.136-.02.275-.039.415-.056-.138.022-.276.04-.415.056-3.912.58-7.387 2.005-2.83 7.078 5.013 5.19 6.87-1.113 7.823-4.308.953 3.195 2.05 9.271 7.733 4.308 4.267-4.308 1.172-6.498-2.74-7.078a8.741 8.741 0 0 1-.415-.056c.14.017.279.036.415.056 2.67.297 5.568-.628 6.383-3.364.246-.828.624-5.79.624-6.478 0-.69-.139-1.861-.902-2.206-.659-.298-1.664-.62-4.3 1.24C16.046 4.748 13.087 8.687 12 10.8Z"/></svg>'
},
link: 'https://bsky.app/profile/fmhy.bsky.social'
}
@ -128,59 +127,79 @@ export const socialLinks: DefaultTheme.SocialLink[] = [
export const sidebar: DefaultTheme.Sidebar | DefaultTheme.NavItemWithLink[] = [
{
text: '<span class="i-twemoji:name-badge"></span> Adblocking / Privacy',
link: '/adblockvpnguide'
text: '<span class="i-twemoji:books"></span> Beginners Guide',
link: '/beginners-guide'
},
{
text: '<span class="i-twemoji:robot"></span> Artificial Intelligence',
link: '/ai'
text: '<span class="i-twemoji:newspaper"></span> Posts',
link: '/posts'
},
{
text: '<span class="i-twemoji:television"></span> Movies / TV / Anime',
link: '/videopiracyguide'
text: '<span class="i-twemoji:light-bulb"></span> Contribute',
link: '/other/contributing'
},
// TODO: genetate sidebar from posts
{
text: 'Wiki',
collapsed: false,
items: [
{
text: '<span class="i-twemoji:name-badge"></span> Adblocking / Privacy',
link: '/adblockvpnguide'
},
{
text: '<span class="i-twemoji:robot"></span> Artificial Intelligence',
link: '/ai'
},
{
text: '<span class="i-twemoji:television"></span> Movies / TV / Anime',
link: '/videopiracyguide'
},
{
text: '<span class="i-twemoji:musical-note"></span> Music / Podcasts / Radio',
link: '/audiopiracyguide'
},
{
text: '<span class="i-twemoji:video-game"></span> Gaming / Emulation',
link: '/gamingpiracyguide'
},
{
text: '<span class="i-twemoji:green-book"></span> Books / Comics / Manga',
link: '/readingpiracyguide'
},
{
text: '<span class="i-twemoji:floppy-disk"></span> Downloading',
link: '/downloadpiracyguide'
},
{
text: '<span class="i-twemoji:cyclone"></span> Torrenting',
link: '/torrentpiracyguide'
},
{
text: '<span class="i-twemoji:brain"></span> Educational',
link: '/edupiracyguide'
},
{
text: '<span class="i-twemoji:mobile-phone"></span> Android / iOS',
link: '/android-iosguide'
},
{
text: '<span class="i-twemoji:penguin"></span> Linux / MacOS',
link: '/linuxguide'
},
{
text: '<span class="i-twemoji:globe-showing-asia-australia"></span> Non-English',
link: '/non-english'
},
{
text: '<span class="i-twemoji:file-folder"></span> Miscellaneous',
link: '/miscguide'
}
]
},
{
text: '<span class="i-twemoji:musical-note"></span> Music / Podcasts / Radio',
link: '/audiopiracyguide'
},
{
text: '<span class="i-twemoji:video-game"></span> Gaming / Emulation',
link: '/gamingpiracyguide'
},
{
text: '<span class="i-twemoji:green-book"></span> Books / Comics / Manga',
link: '/readingpiracyguide'
},
{
text: '<span class="i-twemoji:floppy-disk"></span> Downloading',
link: '/downloadpiracyguide'
},
{
text: '<span class="i-twemoji:cyclone"></span> Torrenting',
link: '/torrentpiracyguide'
},
{
text: '<span class="i-twemoji:brain"></span> Educational',
link: '/edupiracyguide'
},
{
text: '<span class="i-twemoji:mobile-phone"></span> Android / iOS',
link: '/android-iosguide'
},
{
text: '<span class="i-twemoji:penguin"></span> Linux / MacOS',
link: '/linuxguide'
},
{
text: '<span class="i-twemoji:globe-showing-asia-australia"></span> Non-English',
link: '/non-english'
},
{
text: '<span class="i-twemoji:file-folder"></span> Miscellaneous',
link: '/miscguide'
},
{
text: '<span class="i-twemoji:wrench"></span> Tools',
text: 'Tools',
collapsed: false,
items: [
{
@ -230,7 +249,7 @@ export const sidebar: DefaultTheme.Sidebar | DefaultTheme.NavItemWithLink[] = [
]
},
{
text: '<span class="i-twemoji:plus"></span> More',
text: 'More',
collapsed: true,
items: [
{

View file

@ -50,6 +50,12 @@ const { Layout } = DefaultTheme
<template #home-hero-prelink>
<Announcement />
</template>
<template #home-features-before>
<p class="text-center text-lg text-text-2 mb-2">
Or browse these pages
<span class="inline-block i-twemoji:sparkles" />
</p>
</template>
<Content />
</Layout>
</template>

View file

@ -2,7 +2,7 @@
import Authors from './components/Authors.vue'
const props = defineProps<{
authors: string[]
authors: string
}>()
const formatDate = (raw: string): string => {
@ -14,10 +14,11 @@ const formatDate = (raw: string): string => {
}
const { frontmatter } = useData()
const authors = computed(() => props.authors.split(','))
</script>
<template>
<h1>{{ frontmatter.title }}</h1>
<div>{{ frontmatter.description }} {{ formatDate(frontmatter.date) }}</div>
<Authors :authors="props.authors" />
<Authors :authors="authors" />
</template>

View file

@ -15,13 +15,14 @@
*/
import type { Theme } from 'vitepress'
import Components from '@fmhy/components'
import DefaultTheme from 'vitepress/theme'
import { loadProgress } from './composables/nprogress'
import Layout from './Layout.vue'
import Post from './PostLayout.vue'
import './style.scss'
import 'uno.css'
import 'virtual:uno.css'
import Feedback from './components/Feedback.vue'
@ -29,6 +30,7 @@ export default {
extends: DefaultTheme,
Layout,
enhanceApp({ router, app }) {
app.use(Components)
app.component('Post', Post)
app.component('Feedback', Feedback)
loadProgress(router)

View file

@ -1,7 +1,3 @@
import type { ContentData } from 'vitepress'
import { createContentLoader } from 'vitepress'
import { groupBy } from '../utils'
/**
* Copyright (c) taskylizard. All rights reserved.
*
@ -18,18 +14,22 @@ import { groupBy } from '../utils'
* limitations under the License.
*/
import type { ContentData } from 'vitepress'
import { createContentLoader } from 'vitepress'
import { groupBy } from '../utils'
interface Post {
title: string
url: string
date: string
}
type Dictionary = ReturnType
type Dictionary = ReturnType<typeof createContentLoader>
declare const data: Dictionary
export { data }
function transformRawPosts(rawPosts: ContentData[]): Record {
function transformRawPosts(rawPosts: ContentData[]): Record<string, Post[]> {
const posts: Post[] = rawPosts
.map(({ url, frontmatter }) => ({
title: frontmatter.title,