From f28133f42dfc22277268e05f537843afd4b9ff3a Mon Sep 17 00:00:00 2001 From: taskylizard <75871323+taskylizard@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:34:23 +0000 Subject: [PATCH 01/17] fix: adjust homepage icon colors --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 7b4a7595e..d9bca7075 100644 --- a/docs/index.md +++ b/docs/index.md @@ -33,11 +33,11 @@ features: link: /videopiracyguide details: Stream, download, torrent and binge all your favourites movies or shows! - title: Music / Podcasts / Radio - icon: + icon: link: /audiopiracyguide details: Stream, download and torrent songs, podcasts and more! - title: Games / Emulation - icon: + icon: link: /gamingpiracyguide details: Download and play all your favourite games or emulate some old but gold ones! - title: Book / Comics / Manga From 7d8ea01dc0b0a441ff08fe8ee50d8ae3bfa3de95 Mon Sep 17 00:00:00 2001 From: taskylizard <75871323+taskylizard@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:56:45 +0000 Subject: [PATCH 02/17] fix(opengraph): find by headers from file url --- docs/.vitepress/hooks/opengraph.ts | 44 ++++++++++++++++++++++++------ docs/.vitepress/transformer.ts | 12 ++++---- docs/posts.md | 2 ++ unocss.config.ts | 1 - 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/docs/.vitepress/hooks/opengraph.ts b/docs/.vitepress/hooks/opengraph.ts index a9473dea2..f86e52902 100644 --- a/docs/.vitepress/hooks/opengraph.ts +++ b/docs/.vitepress/hooks/opengraph.ts @@ -6,6 +6,7 @@ import type { ContentData, SiteConfig } from 'vitepress' import { type SatoriOptions, satoriVue } from 'x-satori/vue' import { renderAsync } from '@resvg/resvg-js' import consola from 'consola' +import { headers } from '../transformer' const __dirname = dirname(fileURLToPath(import.meta.url)) const __fonts = resolve(__dirname, '../fonts') @@ -67,19 +68,29 @@ async function generateImage({ }: GenerateImagesOptions): Promise { const { frontmatter, url } = page + const _page = getPage(url) + const title = + frontmatter.layout === 'home' + ? frontmatter.hero.name ?? frontmatter.title + : frontmatter.title + ? frontmatter.title + : _page?.title + + const description = + frontmatter.layout === 'home' + ? frontmatter.hero.tagline ?? frontmatter.description + : frontmatter.description + ? frontmatter.description + : _page?.description + + consola.info(url, title, description) const options: SatoriOptions = { width: 1200, height: 628, fonts, props: { - title: - frontmatter.layout === 'home' - ? (frontmatter.hero.name ?? frontmatter.title) - : frontmatter.title, - description: - frontmatter.layout === 'home' - ? (frontmatter.hero.tagline ?? frontmatter.description) - : frontmatter.description + title, + description } } @@ -94,3 +105,20 @@ async function generateImage({ await writeFile(outputFile, render.asPng()) } + +function getPage(page: string) { + // Get the page name + const pageName = `${page}.md`.slice(1).split('/').at(-1) + + // Find the header + // TODO: This is a hacky way to find the header + const header = Object.entries(headers).find(([key]) => key === pageName) + if (!header) return + + const { title, description } = header[1] + + return { + title, + description + } +} diff --git a/docs/.vitepress/transformer.ts b/docs/.vitepress/transformer.ts index c89f7d1e8..6f1f56bb0 100644 --- a/docs/.vitepress/transformer.ts +++ b/docs/.vitepress/transformer.ts @@ -2,10 +2,10 @@ import { basename } from 'pathe' import type { Plugin } from 'vitepress' interface Header { - [key: string]: { title: string; description: string } + [file: string]: { title: string; description: string } } -const headers: Header = { +export const headers: Header = { 'adblockvpnguide.md': { title: 'Adblocking / Privacy', description: "Adblocking, Privacy, VPN's, Proxies, Antivirus" @@ -118,7 +118,7 @@ const headers: Header = { title: 'Unsafe Sites', description: 'Unsafe/harmful sites to avoid.' } -} +} as const const excluded = ['readme.md', 'single-page', 'feedback.md', 'index.md'] @@ -374,7 +374,7 @@ function transformLinks(text: string): string { /\[GitHub\]\(([^\)]*?)\)/gm, '
' ) - // Fallback + // Fallback for GitHub .replace( /\[Github\]\(([^\)]*?)\)/gm, '
' @@ -384,7 +384,7 @@ function transformLinks(text: string): string { /\[GitLab\]\(([^\)]*?)\)/gm, '
' ) - // Fallback + // Fallback for GitLab .replace( /\[Gitlab\]\(([^\)]*?)\)/gm, '
' @@ -397,7 +397,7 @@ function transformLinks(text: string): string { // Transform Subreddit links to icons .replace( /\[Subreddit\]\(([^\)]*?)\)/gm, - '
' + '
' ) return _text } diff --git a/docs/posts.md b/docs/posts.md index 38c89e35d..c8b60835c 100644 --- a/docs/posts.md +++ b/docs/posts.md @@ -1,4 +1,6 @@ --- +title: Posts +description: All our posts, sorted by date. sidebar: false editLink: false outline: false diff --git a/unocss.config.ts b/unocss.config.ts index 012a4ffeb..c20cdc879 100644 --- a/unocss.config.ts +++ b/unocss.config.ts @@ -23,7 +23,6 @@ export default defineConfig({ div: 'var(--vp-c-divider)' } }, - shortcuts, presets: [ presetUno(), presetAttributify(), From 586b45ffa6e8dc0fdb20e31f5d87fadc13689650 Mon Sep 17 00:00:00 2001 From: taskylizard <75871323+taskylizard@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:08:55 +0000 Subject: [PATCH 03/17] [skip-ci] chore: format --- docs/.vitepress/constants.ts | 5 +++-- docs/.vitepress/hooks/opengraph.ts | 4 ++-- docs/.vitepress/theme/components/WallpaperCard.vue | 12 ++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/.vitepress/constants.ts b/docs/.vitepress/constants.ts index 7029c71a5..a3c6d9255 100644 --- a/docs/.vitepress/constants.ts +++ b/docs/.vitepress/constants.ts @@ -11,8 +11,9 @@ export const meta = { export const commitRef = process.env.CF_PAGES && process.env.CF_PAGES_COMMIT_SHA - ? `${process.env.CF_PAGES_COMMIT_SHA.slice(0, 8)}` + ? `${process.env.CF_PAGES_COMMIT_SHA.slice(0, 8)}` : 'dev' export const feedback = `` diff --git a/docs/.vitepress/hooks/opengraph.ts b/docs/.vitepress/hooks/opengraph.ts index f86e52902..2399ab538 100644 --- a/docs/.vitepress/hooks/opengraph.ts +++ b/docs/.vitepress/hooks/opengraph.ts @@ -71,14 +71,14 @@ async function generateImage({ const _page = getPage(url) const title = frontmatter.layout === 'home' - ? frontmatter.hero.name ?? frontmatter.title + ? (frontmatter.hero.name ?? frontmatter.title) : frontmatter.title ? frontmatter.title : _page?.title const description = frontmatter.layout === 'home' - ? frontmatter.hero.tagline ?? frontmatter.description + ? (frontmatter.hero.tagline ?? frontmatter.description) : frontmatter.description ? frontmatter.description : _page?.description diff --git a/docs/.vitepress/theme/components/WallpaperCard.vue b/docs/.vitepress/theme/components/WallpaperCard.vue index 29d6f62c5..5f028f19c 100644 --- a/docs/.vitepress/theme/components/WallpaperCard.vue +++ b/docs/.vitepress/theme/components/WallpaperCard.vue @@ -10,7 +10,9 @@ defineProps<{