style: format with new style

This commit is contained in:
taskylizard 2024-01-25 16:32:45 +00:00
parent bc3bbaafeb
commit ef422dcda8
No known key found for this signature in database
GPG Key ID: 1820131ED1A24120
43 changed files with 686 additions and 583 deletions

View File

@ -20,7 +20,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
cache: 'pnpm'
- run: pnpm install --no-frozen-lockfile

View File

@ -33,7 +33,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: '3.10'
- name: Install dependencies
run: pnpm install
- name: Preprocess files

View File

@ -19,10 +19,10 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: '3.10'
- name: Create local changes
run: python .github/single-page.py
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "♻️ update single page"
commit_message: '♻️ update single page'

View File

@ -1,14 +0,0 @@
{
"semi": true,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "always",
"proseWrap": "always"
}

6
.prettierrc.yaml Normal file
View File

@ -0,0 +1,6 @@
proseWrap: always
semi: false
singleQuote: true
printWidth: 80
trailingComma: none
htmlWhitespaceSensitivity: ignore

View File

@ -1,93 +1,108 @@
import { defineConfig } from "vitepress";
import UnoCSS from "unocss/vite";
import consola from "consola";
import { commitRef, feedback, meta, search, sidebar, socialLinks } from "./constants";
import { generateImages, generateMeta, generateFeed } from "./hooks";
import { toggleStarredPlugin } from "./markdown/toggleStarred";
import { base64DecodePlugin } from "./markdown/base64";
import { movePlugin, emojiRender, defs } from "./markdown/emoji";
import { defineConfig } from 'vitepress'
import UnoCSS from 'unocss/vite'
import consola from 'consola'
import {
commitRef,
feedback,
meta,
search,
sidebar,
socialLinks
} from './constants'
import { generateImages, generateMeta, generateFeed } from './hooks'
import { toggleStarredPlugin } from './markdown/toggleStarred'
import { base64DecodePlugin } from './markdown/base64'
import { movePlugin, emojiRender, defs } from './markdown/emoji'
const baseUrl = process.env.GITHUB_ACTIONS ? "/FMHYedit" : "/";
const baseUrl = process.env.GITHUB_ACTIONS ? '/FMHYedit' : '/'
export default defineConfig({
title: "FMHY",
title: 'FMHY',
description: meta.description,
titleTemplate: ":title • freemediaheckyeah",
lang: "en-US",
titleTemplate: ':title • freemediaheckyeah',
lang: 'en-US',
lastUpdated: false,
cleanUrls: true,
appearance: "dark",
appearance: 'dark',
base: baseUrl,
srcExclude: ["readme.md", "single-page"],
srcExclude: ['readme.md', 'single-page'],
ignoreDeadLinks: true,
sitemap: {
hostname: meta.hostname,
hostname: meta.hostname
},
head: [
["meta", { name: "theme-color", content: "#7bc5e4" }],
["meta", { name: "og:type", content: "website" }],
["meta", { name: "og:locale", content: "en" }],
["link", { rel: "icon", href: "/test.png" }],
['meta', { name: 'theme-color', content: '#7bc5e4' }],
['meta', { name: 'og:type', content: 'website' }],
['meta', { name: 'og:locale', content: 'en' }],
['link', { rel: 'icon', href: '/test.png' }],
// PWA
["link", { rel: "icon", href: "/test.png", type: "image/svg+xml" }],
["link", { rel: "alternate icon", href: "/test.png" }],
["link", { rel: "mask-icon", href: "/test.png", color: "#7bc5e4" }],
['link', { rel: 'icon', href: '/test.png', type: 'image/svg+xml' }],
['link', { rel: 'alternate icon', href: '/test.png' }],
['link', { rel: 'mask-icon', href: '/test.png', color: '#7bc5e4' }],
// prettier-ignore
["meta", { name: "keywords", content: meta.keywords.join(" ") }],
["link", { rel: "apple-touch-icon", href: "/test.png", sizes: "192x192" }],
['link', { rel: 'apple-touch-icon', href: '/test.png', sizes: '192x192' }]
],
transformHead: async (context) => generateMeta(context, meta.hostname),
buildEnd: async (context) => {
generateImages(context)
.then(() => generateFeed(context))
.finally(() => consola.success("Success!"));
.finally(() => consola.success('Success!'))
},
vite: {
optimizeDeps: { exclude: ["workbox-window"] },
optimizeDeps: { exclude: ['workbox-window'] },
plugins: [
UnoCSS({
configFile: "../unocss.config.ts",
configFile: '../unocss.config.ts'
}),
{
name: "custom:adjust-order",
name: 'custom:adjust-order',
configResolved(c) {
movePlugin(c.plugins as any, "vitepress", "before", "unocss:transformers:pre");
},
},
movePlugin(
c.plugins as any,
'vitepress',
'before',
'unocss:transformers:pre'
)
}
}
],
build: {
// Shut the fuck up
chunkSizeWarningLimit: Number.POSITIVE_INFINITY,
},
chunkSizeWarningLimit: Number.POSITIVE_INFINITY
}
},
markdown: {
emoji: { defs },
config(md) {
md.use(emojiRender);
md.use(toggleStarredPlugin);
md.use(base64DecodePlugin);
},
md.use(emojiRender)
md.use(toggleStarredPlugin)
md.use(base64DecodePlugin)
}
},
themeConfig: {
search,
footer: {
message: `${feedback} (rev: ${commitRef})`,
message: `${feedback} (rev: ${commitRef})`
},
outline: "deep",
logo: "/fmhy.ico",
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" },
{ text: "Backups", link: "https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/backups" },
{ text: 'Beginners Guide', link: '/beginners-guide' },
{ text: 'Glossary', link: 'https://rentry.org/The-Piracy-Glossary' },
{ text: 'Guides', link: 'https://rentry.co/fmhy-guides' },
{
text: "About",
items: [
{ text: "Posts", link: "/posts" },
{ text: "Feedback", link: "/feedback" },
],
text: 'Backups',
link: 'https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/backups'
},
{
text: 'About',
items: [
{ text: 'Posts', link: '/posts' },
{ text: 'Feedback', link: '/feedback' }
]
}
],
sidebar,
socialLinks,
},
});
socialLinks
}
})

View File

@ -1,92 +1,101 @@
import type { DefaultTheme } from "vitepress";
import type { DefaultTheme } from 'vitepress'
export const meta = {
name: "FreeMediaHeckYeah",
description: "The largest collection of free stuff on the internet!",
hostname: "https://fmhy.net",
keywords: ["stream", "movies", "gaming", "reading", "anime"],
};
name: 'FreeMediaHeckYeah',
description: 'The largest collection of free stuff on the internet!',
hostname: 'https://fmhy.net',
keywords: ['stream', 'movies', 'gaming', 'reading', 'anime']
}
export const commitRef = process.env.CF_PAGES
? `<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";
: 'dev'
export const feedback = `<a href="/feedback" class="feedback-footer">Made with ❤️</a>`;
export const feedback = `<a href="/feedback" class="feedback-footer">Made with ❤️</a>`
export const search: DefaultTheme.Config["search"] = {
export const search: DefaultTheme.Config['search'] = {
options: {
miniSearch: {
searchOptions: {
combineWith: "AND",
combineWith: 'AND',
fuzzy: false,
// @ts-ignore
boostDocument: (_, term, storedFields: Record<string, string | string[]>) => {
boostDocument: (
_,
term,
storedFields: Record<string, string | string[]>
) => {
const titles = (storedFields?.titles as string[])
.filter((t) => Boolean(t))
.map((t) => t.toLowerCase());
.map((t) => t.toLowerCase())
// Uprate if term appears in titles. Add bonus for higher levels (i.e. lower index)
const titleIndex =
titles.map((t, i) => (t?.includes(term) ? i : -1)).find((i) => i >= 0) ?? -1;
if (titleIndex >= 0) return 10000 - titleIndex;
titles
.map((t, i) => (t?.includes(term) ? i : -1))
.find((i) => i >= 0) ?? -1
if (titleIndex >= 0) return 10000 - titleIndex
return 1;
},
},
return 1
}
}
},
detailedView: true,
detailedView: true
},
provider: "local",
};
provider: 'local'
}
export const socialLinks: DefaultTheme.SocialLink[] = [
{ icon: "github", link: "https://github.com/fmhy/FMHYEdit" },
{ icon: "discord", link: "https://discord.gg/Stz6y6NgNg" },
{ icon: 'github', link: 'https://github.com/fmhy/FMHYEdit' },
{ icon: 'discord', link: 'https://discord.gg/Stz6y6NgNg' },
{
icon: "reddit",
link: "https://reddit.com/r/FREEMEDIAHECKYEAH",
},
];
icon: 'reddit',
link: 'https://reddit.com/r/FREEMEDIAHECKYEAH'
}
]
export const sidebar: DefaultTheme.Sidebar = [
{ text: "📛 Adblocking / Privacy", link: "/adblockvpnguide" },
{ text: "🤖 Artificial Intelligence", link: "/ai" },
{ text: "📺 Movies / TV / Anime", link: "/videopiracyguide" },
{ text: "🎵 Music / Podcasts / Radio", link: "/audiopiracyguide" },
{ text: "🎮 Gaming / Emulation", link: "/gamingpiracyguide" },
{ text: "📗 Books / Comics / Manga", link: "/readingpiracyguide" },
{ text: "💾 Downloading", link: "/downloadpiracyguide" },
{ text: "🌀 Torrenting", link: "/torrentpiracyguide" },
{ text: "🧠 Educational", link: "/edupiracyguide" },
{ text: "📱 Android / iOS", link: "/android-iosguide" },
{ text: "🐧 Linux / MacOS", link: "/linuxguide" },
{ text: "🌍 Non-English", link: "/non-english" },
{ text: "📂 Miscellaneous", link: "/miscguide" },
{ text: '📛 Adblocking / Privacy', link: '/adblockvpnguide' },
{ text: '🤖 Artificial Intelligence', link: '/ai' },
{ text: '📺 Movies / TV / Anime', link: '/videopiracyguide' },
{ text: '🎵 Music / Podcasts / Radio', link: '/audiopiracyguide' },
{ text: '🎮 Gaming / Emulation', link: '/gamingpiracyguide' },
{ text: '📗 Books / Comics / Manga', link: '/readingpiracyguide' },
{ text: '💾 Downloading', link: '/downloadpiracyguide' },
{ text: '🌀 Torrenting', link: '/torrentpiracyguide' },
{ text: '🧠 Educational', link: '/edupiracyguide' },
{ text: '📱 Android / iOS', link: '/android-iosguide' },
{ text: '🐧 Linux / MacOS', link: '/linuxguide' },
{ text: '🌍 Non-English', link: '/non-english' },
{ text: '📂 Miscellaneous', link: '/miscguide' },
{
text: "🔧 Tools",
text: '🔧 Tools',
collapsed: false,
items: [
{ text: "💻 System Tools", link: "/system-tools" },
{ text: "🗃️ File Tools", link: "/file-tools" },
{ text: "🔗 Internet Tools", link: "/internet-tools" },
{ text: "💬 Social Media Tools", link: "/social-media-tools" },
{ text: "📝 Text Tools", link: "/text-tools" },
{ text: "👾 Gaming Tools", link: "/gamingpiracyguide#gaming-tools" },
{ text: "📷 Image Tools", link: "/img-tools" },
{ text: "📼 Video Tools", link: "/video-tools" },
{ text: "🔊 Audio Tools", link: "/audiopiracyguide#audio-tools" },
{ text: "🍎 Educational Tools", link: "/edupiracyguide#educational-tools" },
{ text: "👨‍💻 Developer Tools", link: "/devtools" },
],
{ text: '💻 System Tools', link: '/system-tools' },
{ text: '🗃️ File Tools', link: '/file-tools' },
{ text: '🔗 Internet Tools', link: '/internet-tools' },
{ text: '💬 Social Media Tools', link: '/social-media-tools' },
{ text: '📝 Text Tools', link: '/text-tools' },
{ text: '👾 Gaming Tools', link: '/gamingpiracyguide#gaming-tools' },
{ text: '📷 Image Tools', link: '/img-tools' },
{ text: '📼 Video Tools', link: '/video-tools' },
{ text: '🔊 Audio Tools', link: '/audiopiracyguide#audio-tools' },
{
text: '🍎 Educational Tools',
link: '/edupiracyguide#educational-tools'
},
{ text: '👨‍💻 Developer Tools', link: '/devtools' }
]
},
{
text: " More",
text: ' More',
collapsed: true,
items: [
{ text: "🔞 NSFW", link: "/nsfwpiracy" },
{ text: "⚠️ Unsafe Sites", link: "/unsafesites" },
{ text: "📦 Storage", link: "/storage" },
],
},
];
{ text: '🔞 NSFW', link: '/nsfwpiracy' },
{ text: '⚠️ Unsafe Sites', link: '/unsafesites' },
{ text: '📦 Storage', link: '/storage' }
]
}
]

View File

@ -1,15 +1,20 @@
<script setup lang="ts">
defineProps<{ title: string; description?: string }>();
defineProps<{ title: string; description?: string }>()
</script>
<template>
<div
tw="w-full h-full bg-black flex flex-col"
style="background-image: url(https://fmhy.pages.dev/og.png)">
<div tw="p-10 w-full min-h-0 grow flex flex-col items-center justify-between">
style="background-image: url(https://fmhy.pages.dev/og.png)"
>
<div
tw="p-10 w-full min-h-0 grow flex flex-col items-center justify-between"
>
<div tw="w-full flex justify-between items-center text-5xl font-medium">
<div tw="flex items-center">
<div tw="text-zinc-100 ml-2 mt-1 font-semibold">freemediaheckyeah</div>
<div tw="text-zinc-100 ml-2 mt-1 font-semibold">
freemediaheckyeah
</div>
</div>
</div>
<div tw="w-full pr-56 flex flex-col items-start justify-end">

View File

@ -2,7 +2,7 @@
* Barrel generated using @taskylizard/tasker.
*/
export * from "./meta";
export * from "./opengraph";
export * from "./rss";
export * from "./satoriConfig";
export * from './meta'
export * from './opengraph'
export * from './rss'
export * from './satoriConfig'

View File

@ -1,89 +1,100 @@
import type { HeadConfig, TransformContext } from "vitepress";
import type { HeadConfig, TransformContext } from 'vitepress'
export function generateMeta(context: TransformContext, hostname: string) {
const head: HeadConfig[] = [];
const { pageData } = context;
const head: HeadConfig[] = []
const { pageData } = context
const url = `${hostname}/${pageData.relativePath.replace(/((^|\/)index)?\.md$/, "$2")}`;
const url = `${hostname}/${pageData.relativePath.replace(/((^|\/)index)?\.md$/, '$2')}`
head.push(
["link", { rel: "canonical", href: url }],
["meta", { property: "og:url", content: url }],
["meta", { name: "twitter:url", content: url }],
["meta", { name: "twitter:card", content: "summary_large_image" }],
["meta", { property: "og:title", content: pageData.frontmatter.title }],
["meta", { name: "twitter:title", content: pageData.frontmatter.title }],
);
['link', { rel: 'canonical', href: url }],
['meta', { property: 'og:url', content: url }],
['meta', { name: 'twitter:url', content: url }],
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
['meta', { property: 'og:title', content: pageData.frontmatter.title }],
['meta', { name: 'twitter:title', content: pageData.frontmatter.title }]
)
if (pageData.frontmatter.description) {
head.push(
[
"meta",
'meta',
{
property: "og:description",
content: pageData.frontmatter.description,
},
property: 'og:description',
content: pageData.frontmatter.description
}
],
[
"meta",
'meta',
{
name: "twitter:description",
content: pageData.frontmatter.description,
},
],
);
name: 'twitter:description',
content: pageData.frontmatter.description
}
]
)
}
if (pageData.frontmatter.image) {
head.push([
"meta",
'meta',
{
property: "og:image",
content: `${hostname}/${pageData.frontmatter.image.replace(/^\//, "")}`,
},
]);
property: 'og:image',
content: `${hostname}/${pageData.frontmatter.image.replace(/^\//, '')}`
}
])
head.push([
"meta",
'meta',
{
name: "twitter:image",
content: `${hostname}/${pageData.frontmatter.image.replace(/^\//, "")}`,
},
]);
name: 'twitter:image',
content: `${hostname}/${pageData.frontmatter.image.replace(/^\//, '')}`
}
])
} else {
const url = pageData.filePath.replace("index.md", "").replace(".md", "");
const imageUrl = `${url}/__og_image__/og.png`.replaceAll("//", "/").replace(/^\//, "");
const url = pageData.filePath.replace('index.md', '').replace('.md', '')
const imageUrl = `${url}/__og_image__/og.png`
.replaceAll('//', '/')
.replace(/^\//, '')
head.push(
["meta", { property: "og:image", content: `${hostname}/${imageUrl}` }],
["meta", { property: "og:image:width", content: "1200" }],
["meta", { property: "og:image:height", content: "628" }],
["meta", { property: "og:image:type", content: "image/png" }],
["meta", { property: "og:image:alt", content: pageData.frontmatter.title }],
["meta", { name: "twitter:image", content: `${hostname}/${imageUrl}` }],
["meta", { name: "twitter:image:width", content: "1200" }],
["meta", { name: "twitter:image:height", content: "628" }],
["meta", { name: "twitter:image:alt", content: pageData.frontmatter.title }],
);
['meta', { property: 'og:image', content: `${hostname}/${imageUrl}` }],
['meta', { property: 'og:image:width', content: '1200' }],
['meta', { property: 'og:image:height', content: '628' }],
['meta', { property: 'og:image:type', content: 'image/png' }],
[
'meta',
{ property: 'og:image:alt', content: pageData.frontmatter.title }
],
['meta', { name: 'twitter:image', content: `${hostname}/${imageUrl}` }],
['meta', { name: 'twitter:image:width', content: '1200' }],
['meta', { name: 'twitter:image:height', content: '628' }],
[
'meta',
{ name: 'twitter:image:alt', content: pageData.frontmatter.title }
]
)
}
if (pageData.frontmatter.tag) {
head.push(["meta", { property: "article:tag", content: pageData.frontmatter.tag }]);
head.push([
'meta',
{ property: 'article:tag', content: pageData.frontmatter.tag }
])
}
if (pageData.frontmatter.date) {
head.push([
"meta",
'meta',
{
property: "article:published_time",
content: pageData.frontmatter.date,
},
]);
property: 'article:published_time',
content: pageData.frontmatter.date
}
])
}
if (pageData.lastUpdated && pageData.frontmatter.lastUpdated !== false) {
head.push([
"meta",
'meta',
{
property: "article:modified_time",
content: new Date(pageData.lastUpdated).toISOString(),
},
]);
property: 'article:modified_time',
content: new Date(pageData.lastUpdated).toISOString()
}
])
}
return head;
return head
}

View File

@ -1,71 +1,71 @@
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { createContentLoader } from "vitepress";
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 { mkdir, readFile, writeFile } from 'node:fs/promises'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { createContentLoader } from 'vitepress'
import type { ContentData, SiteConfig } from 'vitepress'
import { type SatoriOptions, satoriVue } from 'x-satori/vue'
import { renderAsync } from '@resvg/resvg-js'
import consola from 'consola'
const __dirname = dirname(fileURLToPath(import.meta.url));
const __fonts = resolve(__dirname, "../fonts");
const __dirname = dirname(fileURLToPath(import.meta.url))
const __fonts = resolve(__dirname, '../fonts')
export async function generateImages(config: SiteConfig): Promise<void> {
const pages = await createContentLoader("**/*.md", { excerpt: true }).load();
const template = await readFile(resolve(__dirname, "./Template.vue"), "utf-8");
const pages = await createContentLoader('**/*.md', { excerpt: true }).load()
const template = await readFile(resolve(__dirname, './Template.vue'), 'utf-8')
const fonts: SatoriOptions["fonts"] = [
const fonts: SatoriOptions['fonts'] = [
{
name: "Inter",
data: await readFile(resolve(__fonts, "Inter-Regular.otf")),
name: 'Inter',
data: await readFile(resolve(__fonts, 'Inter-Regular.otf')),
weight: 400,
style: "normal",
style: 'normal'
},
{
name: "Inter",
data: await readFile(resolve(__fonts, "Inter-Medium.otf")),
name: 'Inter',
data: await readFile(resolve(__fonts, 'Inter-Medium.otf')),
weight: 500,
style: "normal",
style: 'normal'
},
{
name: "Inter",
data: await readFile(resolve(__fonts, "Inter-SemiBold.otf")),
name: 'Inter',
data: await readFile(resolve(__fonts, 'Inter-SemiBold.otf')),
weight: 600,
style: "normal",
style: 'normal'
},
{
name: "Inter",
data: await readFile(resolve(__fonts, "Inter-Bold.otf")),
name: 'Inter',
data: await readFile(resolve(__fonts, 'Inter-Bold.otf')),
weight: 700,
style: "normal",
},
];
style: 'normal'
}
]
for (const page of pages) {
await generateImage({
page,
template,
outDir: config.outDir,
fonts,
});
fonts
})
}
return consola.info("Generated opengraph images.");
return consola.info('Generated opengraph images.')
}
interface GenerateImagesOptions {
page: ContentData;
template: string;
outDir: string;
fonts: SatoriOptions["fonts"];
page: ContentData
template: string
outDir: string
fonts: SatoriOptions['fonts']
}
async function generateImage({
page,
template,
outDir,
fonts,
fonts
}: GenerateImagesOptions): Promise<void> {
const { frontmatter, url } = page;
const { frontmatter, url } = page
const options: SatoriOptions = {
width: 1200,
@ -73,24 +73,24 @@ async function generateImage({
fonts,
props: {
title:
frontmatter.layout === "home"
frontmatter.layout === 'home'
? frontmatter.hero.name ?? frontmatter.title
: frontmatter.title,
description:
frontmatter.layout === "home"
frontmatter.layout === 'home'
? frontmatter.hero.tagline ?? frontmatter.description
: frontmatter.description,
},
};
: frontmatter.description
}
}
const svg = await satoriVue(options, template);
const svg = await satoriVue(options, template)
const render = await renderAsync(svg);
const render = await renderAsync(svg)
const outputFolder = resolve(outDir, url.slice(1), "__og_image__");
const outputFile = resolve(outputFolder, "og.png");
const outputFolder = resolve(outDir, url.slice(1), '__og_image__')
const outputFile = resolve(outputFolder, 'og.png')
await mkdir(outputFolder, { recursive: true });
await mkdir(outputFolder, { recursive: true })
await writeFile(outputFile, render.asPng());
await writeFile(outputFile, render.asPng())
}

View File

@ -1,9 +1,13 @@
import path from "node:path";
import { writeFileSync } from "node:fs";
import { Feed } from "feed";
import { createContentLoader, type ContentData, type SiteConfig } from "vitepress";
import consola from "consola";
import { meta } from "../constants";
import path from 'node:path'
import { writeFileSync } from 'node:fs'
import { Feed } from 'feed'
import {
createContentLoader,
type ContentData,
type SiteConfig
} from 'vitepress'
import consola from 'consola'
import { meta } from '../constants'
export async function generateFeed(config: SiteConfig): Promise<void> {
const feed: Feed = new Feed({
@ -11,32 +15,35 @@ export async function generateFeed(config: SiteConfig): Promise<void> {
link: meta.hostname,
title: `FMHY blog`,
description: meta.description,
language: "en-US",
image: "https://github.com/fmhy.png",
language: 'en-US',
image: 'https://github.com/fmhy.png',
favicon: `${meta.hostname}/favicon.ico`,
copyright: `Copyright (c) 2023-present FMHY`,
});
copyright: `Copyright (c) 2023-present FMHY`
})
const posts: ContentData[] = await createContentLoader("posts/*.md", {
const posts: ContentData[] = await createContentLoader('posts/*.md', {
excerpt: true,
render: true,
transform: (rawData) => {
return rawData.sort((a, b) => {
return Number(new Date(b.frontmatter.date)) - Number(new Date(a.frontmatter.date));
});
},
}).load();
return (
Number(new Date(b.frontmatter.date)) -
Number(new Date(a.frontmatter.date))
)
})
}
}).load()
for (const { url, frontmatter, html } of posts) {
feed.addItem({
title: frontmatter.title as string,
id: `${meta.hostname}${url.replace(/\/\d+\./, "/")}`,
link: `${meta.hostname}${url.replace(/\/\d+\./, "/")}`,
id: `${meta.hostname}${url.replace(/\/\d+\./, '/')}`,
link: `${meta.hostname}${url.replace(/\/\d+\./, '/')}`,
date: frontmatter.date,
content: html!,
});
content: html!
})
}
writeFileSync(path.join(config.outDir, "feed.rss"), feed.rss2());
return consola.info("Generated rss feed.");
writeFileSync(path.join(config.outDir, 'feed.rss'), feed.rss2())
return consola.info('Generated rss feed.')
}

View File

@ -1,47 +1,47 @@
import { readFile } from "node:fs/promises";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import type { SatoriOptions } from "x-satori/vue";
import { defineSatoriConfig } from "x-satori/vue";
import { readFile } from 'node:fs/promises'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import type { SatoriOptions } from 'x-satori/vue'
import { defineSatoriConfig } from 'x-satori/vue'
const __dirname = dirname(fileURLToPath(import.meta.url));
const __fonts = resolve(__dirname, "../fonts");
const __dirname = dirname(fileURLToPath(import.meta.url))
const __fonts = resolve(__dirname, '../fonts')
const fonts: SatoriOptions["fonts"] = [
const fonts: SatoriOptions['fonts'] = [
{
name: "Inter",
data: await readFile(resolve(__fonts, "Inter-Regular.otf")),
name: 'Inter',
data: await readFile(resolve(__fonts, 'Inter-Regular.otf')),
weight: 400,
style: "normal",
style: 'normal'
},
{
name: "Inter",
data: await readFile(resolve(__fonts, "Inter-Medium.otf")),
name: 'Inter',
data: await readFile(resolve(__fonts, 'Inter-Medium.otf')),
weight: 500,
style: "normal",
style: 'normal'
},
{
name: "Inter",
data: await readFile(resolve(__fonts, "Inter-SemiBold.otf")),
name: 'Inter',
data: await readFile(resolve(__fonts, 'Inter-SemiBold.otf')),
weight: 600,
style: "normal",
style: 'normal'
},
{
name: "Inter",
data: await readFile(resolve(__fonts, "Inter-Bold.otf")),
name: 'Inter',
data: await readFile(resolve(__fonts, 'Inter-Bold.otf')),
weight: 700,
style: "normal",
},
];
style: 'normal'
}
]
export default defineSatoriConfig({
width: 1200,
height: 628,
fonts,
props: {
title: "Title",
title: 'Title',
description:
"Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.",
dir: "/j",
},
});
'Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.',
dir: '/j'
}
})

View File

@ -1,25 +1,29 @@
import { type MarkdownRenderer } from "vitepress";
import { type MarkdownRenderer } from 'vitepress'
// FIXME: tasky: possibly write less horror jank?
export function base64DecodePlugin(md: MarkdownRenderer) {
const decode = (str: string): string => Buffer.from(str, "base64").toString("binary");
const decode = (str: string): string =>
Buffer.from(str, 'base64').toString('binary')
// Save the original rule for backticks
const defaultRender =
md.renderer.rules.code_inline ||
function (tokens, idx, options, env, self) {
return self.renderToken(tokens, idx, options);
};
return self.renderToken(tokens, idx, options)
}
md.renderer.rules.code_inline = function (tokens, idx, options, env, self) {
// @ts-expect-error shut the fuck up already I HATE THIS
if (!env.frontmatter.title || (env.frontmatter.title && !env.frontmatter.title === "base64")) {
return defaultRender(tokens, idx, options, env, self);
if (
!env.frontmatter.title ||
(env.frontmatter.title && !env.frontmatter.title === 'base64')
) {
return defaultRender(tokens, idx, options, env, self)
}
const token = tokens[idx];
const content = token.content;
const token = tokens[idx]
const content = token.content
return `<button class='base64' onclick="(function(btn){ const codeEl = btn.querySelector('code'); navigator.clipboard.writeText('${decode(
content,
)}').then(() => { const originalText = codeEl.textContent; codeEl.textContent = 'Copied'; setTimeout(() => codeEl.textContent = originalText, 3000); }).catch(console.error); })(this)"><code>${content}</code></button>`;
};
content
)}').then(() => { const originalText = codeEl.textContent; codeEl.textContent = 'Copied'; setTimeout(() => codeEl.textContent = originalText, 3000); }).catch(console.error); })(this)"><code>${content}</code></button>`
}
}

View File

@ -1,42 +1,42 @@
import { icons as twemoji } from "@iconify-json/twemoji";
import type { MarkdownRenderer } from "vitepress";
import { icons as twemoji } from '@iconify-json/twemoji'
import type { MarkdownRenderer } from 'vitepress'
export const defs = {
...Object.fromEntries(
Object.entries(twemoji.icons).map(([key]) => {
return [key, ""];
}),
),
};
return [key, '']
})
)
}
export function emojiRender(md: MarkdownRenderer) {
md.renderer.rules.emoji = (tokens, idx) => {
if (tokens[idx].markup.startsWith("star")) {
return `<span class="i-twemoji-${tokens[idx].markup} starred"></span>`;
if (tokens[idx].markup.startsWith('star')) {
return `<span class="i-twemoji-${tokens[idx].markup} starred"></span>`
}
return `<span class="i-twemoji-${tokens[idx].markup}"></span>`;
};
return `<span class="i-twemoji-${tokens[idx].markup}"></span>`
}
}
export function movePlugin(
plugins: { name: string }[],
pluginAName: string,
order: "before" | "after",
pluginBName: string,
order: 'before' | 'after',
pluginBName: string
) {
const pluginBIndex = plugins.findIndex((p) => p.name === pluginBName);
if (pluginBIndex === -1) return;
const pluginBIndex = plugins.findIndex((p) => p.name === pluginBName)
if (pluginBIndex === -1) return
const pluginAIndex = plugins.findIndex((p) => p.name === pluginAName);
if (pluginAIndex === -1) return;
const pluginAIndex = plugins.findIndex((p) => p.name === pluginAName)
if (pluginAIndex === -1) return
if (order === "before" && pluginAIndex > pluginBIndex) {
const pluginA = plugins.splice(pluginAIndex, 1)[0];
plugins.splice(pluginBIndex, 0, pluginA);
if (order === 'before' && pluginAIndex > pluginBIndex) {
const pluginA = plugins.splice(pluginAIndex, 1)[0]
plugins.splice(pluginBIndex, 0, pluginA)
}
if (order === "after" && pluginAIndex < pluginBIndex) {
const pluginA = plugins.splice(pluginAIndex, 1)[0];
plugins.splice(pluginBIndex, 0, pluginA);
if (order === 'after' && pluginAIndex < pluginBIndex) {
const pluginA = plugins.splice(pluginAIndex, 1)[0]
plugins.splice(pluginBIndex, 0, pluginA)
}
}

View File

@ -1,18 +1,18 @@
import type { MarkdownRenderer } from "vitepress";
import type { MarkdownRenderer } from 'vitepress'
const excluded = ["Beginners Guide"];
const excluded = ['Beginners Guide']
export function toggleStarredPlugin(md: MarkdownRenderer) {
md.renderer.rules.list_item_open = (tokens, index, options, env, self) => {
const contentToken = tokens[index + 2];
const contentToken = tokens[index + 2]
if (
!excluded.includes(env.frontmatter.title) &&
contentToken &&
contentToken.content.startsWith(":star:")
contentToken.content.startsWith(':star:')
) {
return `<li class="starred">`;
return `<li class="starred">`
} else {
return self.renderToken(tokens, index, options);
return self.renderToken(tokens, index, options)
}
};
}
}

View File

@ -1,6 +1,6 @@
import { corsEventHandler } from "nitro-cors";
import { corsEventHandler } from 'nitro-cors'
export default corsEventHandler((_event) => {}, {
origin: "*",
methods: "*",
});
origin: '*',
methods: '*'
})

View File

@ -1,28 +1,32 @@
import { fetcher } from "itty-fetcher";
import { FeedbackSchema, getFeedbackOption } from "../types/Feedback";
import { fetcher } from 'itty-fetcher'
import { FeedbackSchema, getFeedbackOption } from '../types/Feedback'
export default defineEventHandler(async (event) => {
const { message, page, type } = await readValidatedBody(event, FeedbackSchema.parseAsync);
const env = useRuntimeConfig(event);
const { message, page, type } = await readValidatedBody(
event,
FeedbackSchema.parseAsync
)
const env = useRuntimeConfig(event)
let description = `${message}\n\n`;
if (page) description += `**Page:** \`${page}\``;
let description = `${message}\n\n`
if (page) description += `**Page:** \`${page}\``
await fetcher()
.post(env.WEBHOOK_URL, {
username: "Feedback",
avatar_url: "https://i.kym-cdn.com/entries/icons/facebook/000/043/403/cover3.jpg",
username: 'Feedback',
avatar_url:
'https://i.kym-cdn.com/entries/icons/facebook/000/043/403/cover3.jpg',
embeds: [
{
color: 3447003,
title: getFeedbackOption(type).label,
description,
},
],
description
}
]
})
.catch((error) => {
throw new Error(error);
});
throw new Error(error)
})
return { status: "ok" };
});
return { status: 'ok' }
})

View File

@ -1,3 +1,3 @@
export default eventHandler(() => {
return { nitro: "works" };
});
return { nitro: 'works' }
})

View File

@ -1,47 +1,47 @@
<script setup lang="ts">
import DefaultTheme from "vitepress/theme";
import { useData } from "vitepress";
import { nextTick, provide } from "vue";
import Sidebar from "./components/SidebarCard.vue";
import Announcement from "./components/Announcement.vue";
import DefaultTheme from 'vitepress/theme'
import { useData } from 'vitepress'
import { nextTick, provide } from 'vue'
import Sidebar from './components/SidebarCard.vue'
import Announcement from './components/Announcement.vue'
const { isDark } = useData();
const { isDark } = useData()
const enableTransitions = () =>
"startViewTransition" in document &&
window.matchMedia("(prefers-reduced-motion: no-preference)").matches;
'startViewTransition' in document &&
window.matchMedia('(prefers-reduced-motion: no-preference)').matches
provide("toggle-appearance", async ({ clientX: x, clientY: y }: MouseEvent) => {
provide('toggle-appearance', async ({ clientX: x, clientY: y }: MouseEvent) => {
if (!enableTransitions()) {
isDark.value = !isDark.value;
return;
isDark.value = !isDark.value
return
}
const clipPath = [
`circle(0px at ${x}px ${y}px)`,
`circle(${Math.hypot(
Math.max(x, innerWidth - x),
Math.max(y, innerHeight - y),
)}px at ${x}px ${y}px)`,
];
Math.max(y, innerHeight - y)
)}px at ${x}px ${y}px)`
]
// @ts-expect-error
await document.startViewTransition(async () => {
isDark.value = !isDark.value;
await nextTick();
}).ready;
isDark.value = !isDark.value
await nextTick()
}).ready
document.documentElement.animate(
{ clipPath: isDark.value ? clipPath.reverse() : clipPath },
{
duration: 300,
easing: "ease-in",
pseudoElement: `::view-transition-${isDark.value ? "old" : "new"}(root)`,
},
);
});
easing: 'ease-in',
pseudoElement: `::view-transition-${isDark.value ? 'old' : 'new'}(root)`
}
)
})
const { Layout } = DefaultTheme;
const { Layout } = DefaultTheme
</script>
<template>

View File

@ -1,20 +1,20 @@
<script setup lang="ts">
import { useData } from "vitepress";
import Authors from "./components/Authors.vue";
import { useData } from 'vitepress'
import Authors from './components/Authors.vue'
const props = defineProps<{
authors: string[];
}>();
authors: string[]
}>()
const formatDate = (raw: string): string => {
const date = new Date(raw);
return date.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
});
};
const date = new Date(raw)
return date.toLocaleDateString('en-US', {
month: 'short',
day: 'numeric'
})
}
const { frontmatter } = useData();
const { frontmatter } = useData()
</script>
<template>
@ -22,6 +22,8 @@ const { frontmatter } = useData();
{{ frontmatter.title }}
</h3>
<span>{{ frontmatter.description }} {{ formatDate(frontmatter.date) }}</span>
<span>
{{ frontmatter.description }} {{ formatDate(frontmatter.date) }}
</span>
<Authors :authors="props.authors" />
</template>

View File

@ -1,14 +1,14 @@
<!-- eslint-disable vue/require-v-for-key -->
<script setup lang="ts">
import { data as posts } from "./posts.data";
import { data as posts } from './posts.data'
const formatDate = (raw: string): string => {
const date = new Date(raw);
return date.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
});
};
const date = new Date(raw)
return date.toLocaleDateString('en-US', {
month: 'short',
day: 'numeric'
})
}
</script>
<template>
@ -28,11 +28,14 @@ const formatDate = (raw: string): string => {
<ul>
<li v-for="post of posts[year]" :key="post.url">
<article>
<a :href="post.url" class="border-none">{{ post.title }}</a> -
<a :href="post.url" class="border-none">{{ post.title }}</a>
-
<dl class="m-0 inline">
<dt class="sr-only">Published on</dt>
<dd class="m-0 inline">
<time :datetime="post.date" class="font-bold">{{ formatDate(post.date) }}</time>
<time :datetime="post.date" class="font-bold">
{{ formatDate(post.date) }}
</time>
</dd>
</dl>
</article>

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { useData } from "vitepress";
import { useData } from 'vitepress'
const { frontmatter } = useData();
const { frontmatter } = useData()
</script>
<template>
@ -9,7 +9,8 @@ const { frontmatter } = useData();
v-if="frontmatter.hero.prelink"
:href="frontmatter.hero.prelink.link"
target="_blank"
class="inline-flex items-center rounded-lg bg-[var(--vp-c-default-soft)] px-4 py-1 text-sm font-semibold mb-3">
class="inline-flex items-center rounded-lg bg-[var(--vp-c-default-soft)] px-4 py-1 text-sm font-semibold mb-3"
>
{{ frontmatter.hero.prelink.title }}
</a>
</template>

View File

@ -1,39 +1,41 @@
<script setup lang="ts">
import { computed } from "vue";
import { computed } from 'vue'
const props = defineProps<{
authors: string[];
}>();
authors: string[]
}>()
interface Author {
name: string;
github: string;
name: string
github: string
}
const data = [
{
name: "nbats",
github: "https://github.com/nbats",
name: 'nbats',
github: 'https://github.com/nbats'
},
{
name: "Kai",
github: "https://github.com/Kai-FMHY",
name: 'Kai',
github: 'https://github.com/Kai-FMHY'
},
{
name: "taskylizard",
github: "https://github.com/taskylizard",
name: 'taskylizard',
github: 'https://github.com/taskylizard'
},
{
name: "zinklog",
github: "https://github.com/zinklog2",
name: 'zinklog',
github: 'https://github.com/zinklog2'
},
{
name: "Q",
github: "https://github.com/qiracy",
},
] satisfies Author[];
name: 'Q',
github: 'https://github.com/qiracy'
}
] satisfies Author[]
const authors = computed(() => data.filter((author) => props.authors.includes(author.name)));
const authors = computed(() =>
data.filter((author) => props.authors.includes(author.name))
)
</script>
<template>
@ -41,7 +43,7 @@ const authors = computed(() => data.filter((author) => props.authors.includes(au
<div v-for="(c, index) of authors" class="flex gap-2 items-center">
<img :src="`${c.github}.png`" class="w-8 h-8 rounded-full" />
<a :href="c.github">{{ c.name }}</a>
<span v-if="index < authors.length - 1"> </span>
<span v-if="index < authors.length - 1"></span>
</div>
</div>
</template>

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
defineProps<{
icon: string;
}>();
icon: string
}>()
</script>
<template>

View File

@ -1,48 +1,52 @@
<script setup lang="ts">
import { reactive, ref } from "vue";
import { useRouter } from "vitepress";
import { type FeedbackType, getFeedbackOption, feedbackOptions } from "../../types/Feedback";
import { reactive, ref } from 'vue'
import { useRouter } from 'vitepress'
import {
type FeedbackType,
getFeedbackOption,
feedbackOptions
} from '../../types/Feedback'
const loading = ref<boolean>(false);
const error = ref<unknown>(null);
const success = ref<boolean>(false);
const loading = ref<boolean>(false)
const error = ref<unknown>(null)
const success = ref<boolean>(false)
const router = useRouter();
const router = useRouter()
const feedback = reactive<FeedbackType>({ message: "" });
const feedback = reactive<FeedbackType>({ message: '' })
async function handleSubmit(type?: FeedbackType["type"]) {
if (type) feedback.type = type;
loading.value = true;
async function handleSubmit(type?: FeedbackType['type']) {
if (type) feedback.type = type
loading.value = true
const body: FeedbackType = {
message: feedback.message,
type: feedback.type,
page: router.route.path,
};
page: router.route.path
}
try {
const response = await fetch("https://feedback.tasky.workers.dev", {
method: "POST",
const response = await fetch('https://feedback.tasky.workers.dev', {
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json'
},
body: JSON.stringify(body),
});
body: JSON.stringify(body)
})
const data = await response.json();
const data = await response.json()
if (data.error) {
error.value = data.error;
return;
error.value = data.error
return
}
if (data.status === "ok") {
success.value = true;
if (data.status === 'ok') {
success.value = true
}
} catch (error) {
error.value = error;
error.value = error
} finally {
loading.value = false;
loading.value = false
}
}
</script>
@ -61,7 +65,8 @@ async function handleSubmit(type?: FeedbackType["type"]) {
v-for="item in feedbackOptions"
:key="item.value"
class="btn"
@click="handleSubmit(item.value as FeedbackType['type'])">
@click="handleSubmit(item.value as FeedbackType['type'])"
>
<span>{{ item.label }}</span>
</button>
</div>
@ -71,7 +76,11 @@ async function handleSubmit(type?: FeedbackType["type"]) {
<p class="desc">Page: {{ router.route.path }}</p>
<div>
<span>{{ getFeedbackOption(feedback.type)?.label }}</span>
<button style="margin-left: 0.5rem" class="btn" @click="feedback.type = undefined">
<button
style="margin-left: 0.5rem"
class="btn"
@click="feedback.type = undefined"
>
<span class="i-carbon-close-large">close</span>
</button>
</div>
@ -80,19 +89,27 @@ async function handleSubmit(type?: FeedbackType["type"]) {
v-model="feedback.message"
autofocus
class="input"
placeholder="What a lovely wiki!" />
placeholder="What a lovely wiki!"
/>
<p class="desc mb-2">
If you'd prefer to be contacted through another platform, feel free to mention it in the
message or join our
<a class="text-primary font-semibold text-underline" href="https://discord.gg/Stz6y6NgNg"
>Discord</a
>.
If you'd prefer to be contacted through another platform, feel free to
mention it in the message or join our
<a
class="text-primary font-semibold text-underline"
href="https://discord.gg/Stz6y6NgNg"
>
Discord
</a>
.
</p>
<button
type="submit"
class="btn btn-primary"
:disabled="feedback.message.length < 5 || feedback.message.length > 1000"
@click="handleSubmit()">
:disabled="
feedback.message.length < 5 || feedback.message.length > 1000
"
@click="handleSubmit()"
>
Submit
</button>
</div>

View File

@ -1,34 +1,34 @@
<script setup lang="ts">
import { ref } from "vue";
import { ref } from 'vue'
import {
TransitionRoot,
TransitionChild,
Dialog,
DialogPanel,
DialogTitle,
DialogDescription,
} from "@headlessui/vue";
DialogDescription
} from '@headlessui/vue'
const isOpen = ref(true);
const isOpen = ref(true)
const feedbackOptions = [
{
label: "💡 Suggestion",
value: "suggestion",
label: '💡 Suggestion',
value: 'suggestion'
},
{
label: "❤️ Appreciation",
value: "appreciate",
label: '❤️ Appreciation',
value: 'appreciate'
},
{ label: "🐞 Bug", value: "bug" },
{ label: "📂 Other", value: "other" },
];
{ label: '🐞 Bug', value: 'bug' },
{ label: '📂 Other', value: 'other' }
]
function closeModal() {
isOpen.value = false;
isOpen.value = false
}
function openModal() {
isOpen.value = true;
isOpen.value = true
}
</script>
@ -36,7 +36,8 @@ function openModal() {
<button
type="button"
class="p-[4px 8px] text-xl i-carbon:user-favorite-alt-filled"
@click="openModal" />
@click="openModal"
/>
<TransitionRoot appear :show="isOpen" as="template">
<Dialog as="div" class="relative z-10" @close="closeModal">
@ -47,12 +48,15 @@ function openModal() {
enter-to="opacity-100"
leave="duration-200 ease-in"
leave-from="opacity-100"
leave-to="opacity-0">
leave-to="opacity-0"
>
<div class="fixed inset-0 bg-black/25" />
</TransitionChild>
<div class="fixed inset-0 overflow-y-auto">
<div class="flex min-h-full items-center justify-center p-4 text-center">
<div
class="flex min-h-full items-center justify-center p-4 text-center"
>
<TransitionChild
as="template"
enter="duration-300 ease-out"
@ -60,10 +64,15 @@ function openModal() {
enter-to="opacity-100 scale-100"
leave="duration-200 ease-in"
leave-from="opacity-100 scale-100"
leave-to="opacity-0 scale-95">
leave-to="opacity-0 scale-95"
>
<DialogPanel
class="w-full max-w-md transform overflow-hidden rounded-2xl bg-bg p-6 text-left align-middle shadow-xl transition-all">
<DialogTitle as="h3" class="text-lg font-medium leading-6 text-text">
class="w-full max-w-md transform overflow-hidden rounded-2xl bg-bg p-6 text-left align-middle shadow-xl transition-all"
>
<DialogTitle
as="h3"
class="text-lg font-medium leading-6 text-text"
>
Feedback
</DialogTitle>
@ -72,7 +81,8 @@ function openModal() {
<button
v-for="item in feedbackOptions"
:key="item.value"
class="inline-flex justify-center rounded-md border border-transparent bg-bg-alt px-4 py-2 text-sm font-medium text-text hover:border-primary focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2">
class="inline-flex justify-center rounded-md border border-transparent bg-bg-alt px-4 py-2 text-sm font-medium text-text hover:border-primary focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2"
>
<span>{{ item.label }}</span>
</button>
</div>
@ -90,7 +100,8 @@ function openModal() {
<button
type="button"
class="inline-flex justify-center rounded-md border border-transparent bg-blue-100 px-4 py-2 text-sm font-medium text-blue-900 hover:bg-blue-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2"
@click="closeModal">
@click="closeModal"
>
Close
</button>
</div>

View File

@ -1,8 +1,8 @@
<script setup lang="ts">
defineProps<{
label: string;
id: string;
}>();
label: string
id: string
}>()
</script>
<template>

View File

@ -1,12 +1,15 @@
<script setup lang="ts">
import { ref } from "vue";
import Feedback from "./Feedback.vue";
import { ref } from 'vue'
import Feedback from './Feedback.vue'
const showModal = ref(false);
const showModal = ref(false)
</script>
<template>
<button class="p-[4px 8px] text-xl i-carbon:user-favorite-alt-filled" @click="showModal = true" />
<button
class="p-[4px 8px] text-xl i-carbon:user-favorite-alt-filled"
@click="showModal = true"
/>
<Teleport to="body">
<Transition name="modal">
@ -14,7 +17,9 @@ const showModal = ref(false);
<div class="modal-container">
<Feedback />
<div class="model-footer">
<button class="modal-button" @click="showModal = false">Close</button>
<button class="modal-button" @click="showModal = false">
Close
</button>
</div>
</div>
</div>

View File

@ -1,8 +1,8 @@
<script setup lang="ts">
import Field from "./CardField.vue";
import Modal from "./Modal.vue";
import InputField from "./InputField.vue";
import ToggleStarred from "./ToggleStarred.vue";
import Field from './CardField.vue'
import Modal from './Modal.vue'
import InputField from './InputField.vue'
import ToggleStarred from './ToggleStarred.vue'
</script>
<template>
@ -10,9 +10,9 @@ import ToggleStarred from "./ToggleStarred.vue";
<div class="card-header">
<div class="card-title">Emoji Legend</div>
</div>
<Field icon="i-twemoji-star"> Recommendations </Field>
<Field icon="i-twemoji-globe-with-meridians"> Indexes </Field>
<Field icon="i-twemoji-repeat-button"> Storage Links </Field>
<Field icon="i-twemoji-star">Recommendations</Field>
<Field icon="i-twemoji-globe-with-meridians">Indexes</Field>
<Field icon="i-twemoji-repeat-button">Storage Links</Field>
<div class="card-header">
<div class="card-title">Options</div>
</div>

View File

@ -1,8 +1,8 @@
<script setup>
import { ref } from "vue";
import { Switch } from "@headlessui/vue";
import { ref } from 'vue'
import { Switch } from '@headlessui/vue'
const enabled = ref(false);
const enabled = ref(false)
</script>
<template>

View File

@ -1,7 +1,8 @@
<script setup lang="ts">
import Switch from "./Switch.vue";
import Switch from './Switch.vue'
const toggleStarred = () => document.documentElement.classList.toggle("starred-only");
const toggleStarred = () =>
document.documentElement.classList.toggle('starred-only')
</script>
<template>

View File

@ -1,23 +1,23 @@
import nprogress, { type NProgress } from "nprogress";
import type { EnhanceAppContext } from "vitepress";
import nprogress, { type NProgress } from 'nprogress'
import type { EnhanceAppContext } from 'vitepress'
export function loadProgress(router: EnhanceAppContext["router"]): NProgress {
if (typeof window === "undefined") return;
export function loadProgress(router: EnhanceAppContext['router']): NProgress {
if (typeof window === 'undefined') return
setTimeout(() => {
nprogress.configure({ showSpinner: false });
nprogress.configure({ showSpinner: false })
const cacheBeforeRouteChange = router.onBeforeRouteChange;
const cacheAfterRouteChange = router.onAfterRouteChanged;
const cacheBeforeRouteChange = router.onBeforeRouteChange
const cacheAfterRouteChange = router.onAfterRouteChanged
router.onBeforeRouteChange = (to) => {
nprogress.start();
cacheBeforeRouteChange?.(to);
};
nprogress.start()
cacheBeforeRouteChange?.(to)
}
router.onAfterRouteChanged = (to) => {
nprogress.done();
cacheAfterRouteChange?.(to);
};
});
nprogress.done()
cacheAfterRouteChange?.(to)
}
})
return nprogress;
return nprogress
}

View File

@ -1,16 +1,16 @@
import { type Theme } from "vitepress";
import DefaultTheme from "vitepress/theme";
import Layout from "./Layout.vue";
import Post from "./PostLayout.vue";
import { loadProgress } from "./composables/nprogress";
import "./style.css";
import "uno.css";
import { type Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import Layout from './Layout.vue'
import Post from './PostLayout.vue'
import { loadProgress } from './composables/nprogress'
import './style.css'
import 'uno.css'
export default {
extends: DefaultTheme,
Layout,
enhanceApp({ router, app }) {
app.component("Post", Post);
loadProgress(router);
},
} satisfies Theme;
app.component('Post', Post)
loadProgress(router)
}
} satisfies Theme

View File

@ -1,30 +1,30 @@
import { createContentLoader, type ContentData } from "vitepress";
import { groupBy } from "../utils";
import { createContentLoader, type ContentData } from 'vitepress'
import { groupBy } from '../utils'
interface Post {
title: string;
url: string;
date: string;
title: string
url: string
date: string
}
type Dictionary = ReturnType<typeof transformRawPosts>;
type Dictionary = ReturnType<typeof transformRawPosts>
declare const data: Dictionary;
export { data };
declare const data: Dictionary
export { data }
function transformRawPosts(rawPosts: ContentData[]): Record<string, Post[]> {
const posts: Post[] = rawPosts
.map(({ url, frontmatter }) => ({
title: frontmatter.title,
url,
date: (frontmatter.date as Date).toISOString().slice(0, 10),
date: (frontmatter.date as Date).toISOString().slice(0, 10)
}))
.sort((a, b) => b.date.localeCompare(a.date));
.sort((a, b) => b.date.localeCompare(a.date))
return groupBy(posts, (post) => post.date.slice(0, 4));
return groupBy(posts, (post) => post.date.slice(0, 4))
}
export default createContentLoader("posts/*.md", {
export default createContentLoader('posts/*.md', {
includeSrc: true,
transform: (raw) => transformRawPosts(raw),
});
transform: (raw) => transformRawPosts(raw)
})

View File

@ -124,9 +124,17 @@
*/
:root {
--vp-home-hero-name-color: transparent;
--vp-home-hero-name-background: -webkit-linear-gradient(120deg, #c4b5fd 30%, #7bc5e4);
--vp-home-hero-name-background: -webkit-linear-gradient(
120deg,
#c4b5fd 30%,
#7bc5e4
);
--vp-home-hero-image-background-image: linear-gradient(-45deg, #c4b5fd 50%, #47caff 50%);
--vp-home-hero-image-background-image: linear-gradient(
-45deg,
#c4b5fd 50%,
#47caff 50%
);
--vp-home-hero-image-filter: blur(44px);
}

View File

@ -1,26 +1,29 @@
import z from "zod";
import z from 'zod'
export const FeedbackSchema = z.object({
message: z.string().min(5).max(1000),
type: z.enum(["bug", "suggestion", "appreciate", "other"]),
page: z.string().optional(),
});
type: z.enum(['bug', 'suggestion', 'appreciate', 'other']),
page: z.string().optional()
})
export const feedbackOptions = [
{ label: "🐞 Bug", value: "bug" },
{ label: '🐞 Bug', value: 'bug' },
{
label: "💡 Suggestion",
value: "suggestion",
label: '💡 Suggestion',
value: 'suggestion'
},
{ label: "📂 Other", value: "other" },
{ label: '📂 Other', value: 'other' },
{
label: "❤️ Appreciation",
value: "appreciate",
},
];
label: '❤️ Appreciation',
value: 'appreciate'
}
]
export function getFeedbackOption(value: string): { label: string; value: string } {
return feedbackOptions.find((option) => option.value === value);
export function getFeedbackOption(value: string): {
label: string
value: string
} {
return feedbackOptions.find((option) => option.value === value)
}
export type FeedbackType = z.infer<typeof FeedbackSchema>;
export type FeedbackType = z.infer<typeof FeedbackSchema>

View File

@ -1,9 +1,12 @@
export function groupBy<T, K extends keyof any>(arr: T[], key: (i: T) => K): Record<K, T[]> {
export function groupBy<T, K extends keyof any>(
arr: T[],
key: (i: T) => K
): Record<K, T[]> {
return arr.reduce(
(groups, item) => {
(groups[key(item)] ||= []).push(item);
return groups;
;(groups[key(item)] ||= []).push(item)
return groups
},
{} as Record<K, T[]>,
);
{} as Record<K, T[]>
)
}

View File

@ -1,5 +1,5 @@
/* eslint-disable ts/consistent-type-imports */
declare module "*.vue" {
const component: import("vue").Component;
export default component;
declare module '*.vue' {
const component: import('vue').Component
export default component
}

View File

@ -1,7 +1,7 @@
// @ts-check
import tasky from "@taskylizard/eslint-config";
import tasky from '@taskylizard/eslint-config'
export default tasky({
vue: true,
browser: true,
});
browser: true
})

View File

@ -1,12 +1,12 @@
//https://nitro.unjs.io/config
export default defineNitroConfig({
runtimeConfig: {
WEBHOOK_URL: process.env.WEBHOOK_URL,
WEBHOOK_URL: process.env.WEBHOOK_URL
},
srcDir: ".vitepress",
srcDir: '.vitepress',
routeRules: {
"/": {
cors: false,
},
},
});
'/': {
cors: false
}
}
})

View File

@ -1,7 +1,7 @@
{
"extends": "./.nitro/types/tsconfig.json",
"compilerOptions": {
"verbatimModuleSyntax": true,
"verbatimModuleSyntax": true
},
"include": ["./.vitepress/"],
"include": ["./.vitepress/"]
}

View File

@ -1,16 +1,16 @@
import { defineConfig, presetUno, presetAttributify, presetIcons } from "unocss";
import { defineConfig, presetUno, presetAttributify, presetIcons } from 'unocss'
export default defineConfig({
theme: {
colors: {
primary: "var(--vp-c-brand-1)",
bg: "var(--vp-c-bg)",
"bg-alt": "var(--vp-c-bg-alt)",
"bg-elv": "var(--vp-c-bg-elv)",
text: "var(--vp-c-text-1)",
"text-2": "var(--vp-c-text-2)",
div: "var(--vp-c-divider)",
},
primary: 'var(--vp-c-brand-1)',
bg: 'var(--vp-c-bg)',
'bg-alt': 'var(--vp-c-bg-alt)',
'bg-elv': 'var(--vp-c-bg-elv)',
text: 'var(--vp-c-text-1)',
'text-2': 'var(--vp-c-text-2)',
div: 'var(--vp-c-divider)'
}
},
presets: [
presetUno(),
@ -18,9 +18,9 @@ export default defineConfig({
presetIcons({
scale: 1.2,
extraProperties: {
display: "inline-block",
"vertical-align": "middle",
},
}),
],
});
display: 'inline-block',
'vertical-align': 'middle'
}
})
]
})