From d87ab7fc72ea0864a7f496493b7da48f9cdb2ab0 Mon Sep 17 00:00:00 2001 From: Soitora Date: Tue, 5 Sep 2023 22:36:12 +0200 Subject: [PATCH] Lint project --- website/src/.vitepress/config.ts | 2 +- .../.vitepress/config/hooks/generateMeta.ts | 8 +-- .../config/hooks/generateOgImages.ts | 30 ++++---- .../src/.vitepress/config/markdownConfig.ts | 17 +++-- .../.vitepress/config/navigation/navbar.ts | 2 +- website/src/.vitepress/config/shortcodes.ts | 70 +++++++++---------- website/src/.vitepress/config/themeConfig.ts | 2 +- .../theme/components/Changelogs.vue | 12 ++-- .../theme/components/Contributors.vue | 28 ++++---- .../theme/components/ExtensionGroup.vue | 50 ------------- .../components/Extensions/ExtensionItem.vue | 6 +- .../src/.vitepress/theme/components/News.vue | 35 +++++++--- .../theme/components/OgImageTemplate.vue | 2 +- .../.vitepress/theme/components/WhatsNew.vue | 2 +- .../.vitepress/theme/data/changelogs.data.ts | 4 +- .../src/.vitepress/theme/data/news.data.ts | 19 ++--- .../src/.vitepress/theme/data/release.data.ts | 4 +- website/src/.vitepress/theme/styles/base.styl | 12 ++-- .../.vitepress/theme/styles/forks/lint.styl | 9 +++ 19 files changed, 143 insertions(+), 171 deletions(-) delete mode 100644 website/src/.vitepress/theme/components/ExtensionGroup.vue create mode 100644 website/src/.vitepress/theme/styles/forks/lint.styl diff --git a/website/src/.vitepress/config.ts b/website/src/.vitepress/config.ts index 31cba279..ad5cb3b7 100644 --- a/website/src/.vitepress/config.ts +++ b/website/src/.vitepress/config.ts @@ -11,7 +11,7 @@ import generateOgImages from "./config/hooks/generateOgImages"; const title = "Tachiyomi"; const description = "Read your favorite manga, webtoons, comics, and more – easier than ever on your Android."; -const env = loadEnv("", process.cwd()) +const env = loadEnv("", process.cwd()); const hostname: string = env.VITE_HOSTNAME || "http://localhost:4173"; export default defineConfig({ diff --git a/website/src/.vitepress/config/hooks/generateMeta.ts b/website/src/.vitepress/config/hooks/generateMeta.ts index 6127780f..f269a4a3 100644 --- a/website/src/.vitepress/config/hooks/generateMeta.ts +++ b/website/src/.vitepress/config/hooks/generateMeta.ts @@ -69,12 +69,8 @@ const generateMeta = (context: TransformContext, hostname: string) => { }, ]); } else { - const url = pageData.filePath - .replace("index.md", "") - .replace(".md", ""); - const imageUrl = `${url}/__og_image__/og.png` - .replace(/\/\//g, "/") - .replace(/^\//, ""); + const url = pageData.filePath.replace("index.md", "").replace(".md", ""); + const imageUrl = `${url}/__og_image__/og.png`.replace(/\/\//g, "/").replace(/^\//, ""); head.push(["meta", { property: "og:image", content: `${hostname}/${imageUrl}` }]); head.push(["meta", { property: "og:image:width", content: "1200" }]); diff --git a/website/src/.vitepress/config/hooks/generateOgImages.ts b/website/src/.vitepress/config/hooks/generateOgImages.ts index e85b9586..4acdfd16 100644 --- a/website/src/.vitepress/config/hooks/generateOgImages.ts +++ b/website/src/.vitepress/config/hooks/generateOgImages.ts @@ -10,7 +10,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url)); const __fonts = resolve(__dirname, "../../fonts"); async function generateOgImages(config: SiteConfig) { - const pages = await createContentLoader("**/*.md", { excerpt: true }).load() + const pages = await createContentLoader("**/*.md", { excerpt: true }).load(); const template = await readFile(resolve(__dirname, "../../theme/components/OgImageTemplate.vue"), "utf-8"); const fonts: SatoriOptions["fonts"] = [ @@ -40,14 +40,14 @@ async function generateOgImages(config: SiteConfig) { }, ]; - const filteredPages = pages.filter(p => p.frontmatter.image === undefined); + const filteredPages = pages.filter((p) => p.frontmatter.image === undefined); for (const page of filteredPages) { await generateImage({ page, template, outDir: config.outDir, - fonts + fonts, }); } } @@ -69,19 +69,17 @@ async function generateImage({ page, template, outDir, fonts }: GenerateImagesOp height: 628, fonts, props: { - title: frontmatter.layout === "home" - ? (frontmatter.hero.name ?? frontmatter.title.replace(/\s\-.*$/, "")) - : (frontmatter.customMetaTitle ?? frontmatter.title.replace(/\s\-.*$/, "")), - description: frontmatter.layout === "home" - ? (frontmatter.hero.tagline ?? frontmatter.description) - : frontmatter.description, - dir: (url.startsWith("/docs/faq/")) - ? "FAQ" - : (url.startsWith("/docs/guides/")) - ? "Guide" - : undefined, - } - } + title: + frontmatter.layout === "home" + ? frontmatter.hero.name ?? frontmatter.title.replace(/\s\-.*$/, "") + : frontmatter.customMetaTitle ?? frontmatter.title.replace(/\s\-.*$/, ""), + description: + frontmatter.layout === "home" + ? frontmatter.hero.tagline ?? frontmatter.description + : frontmatter.description, + dir: url.startsWith("/docs/faq/") ? "FAQ" : url.startsWith("/docs/guides/") ? "Guide" : undefined, + }, + }; const svg = await satoriVue(options, template); diff --git a/website/src/.vitepress/config/markdownConfig.ts b/website/src/.vitepress/config/markdownConfig.ts index 5b6e009a..e7e49a00 100644 --- a/website/src/.vitepress/config/markdownConfig.ts +++ b/website/src/.vitepress/config/markdownConfig.ts @@ -13,18 +13,17 @@ import shortcodes from "./shortcodes"; const markdownConfig: MarkdownOptions = { config: (md) => { md.use(attrs), - md.use(figure), - md.use(imgLazyload), - md.use(imgMark), - md.use(imgSize), - md.use(include, { - currentPath: (env) => env.filePath, - }), - md.use(tabsMarkdownPlugin); + md.use(figure), + md.use(imgLazyload), + md.use(imgMark), + md.use(imgSize), + md.use(include, { + currentPath: (env) => env.filePath, + }), + md.use(tabsMarkdownPlugin); md.use(shortcode_plugin, shortcodes); }, - }; export default markdownConfig; diff --git a/website/src/.vitepress/config/navigation/navbar.ts b/website/src/.vitepress/config/navigation/navbar.ts index a0de1d1b..8e1ef8c8 100644 --- a/website/src/.vitepress/config/navigation/navbar.ts +++ b/website/src/.vitepress/config/navigation/navbar.ts @@ -8,7 +8,7 @@ const nav = [ }, { text: APP_VERSION, - activeMatch: "^\/*?(download|changelogs)\/*?$", + activeMatch: "^/*?(download|changelogs)/*?$", items: [ { text: "Download", diff --git a/website/src/.vitepress/config/shortcodes.ts b/website/src/.vitepress/config/shortcodes.ts index 407cead7..be9fdef7 100644 --- a/website/src/.vitepress/config/shortcodes.ts +++ b/website/src/.vitepress/config/shortcodes.ts @@ -1,54 +1,54 @@ const navigationMappings = { - more: { - name: "More", + more: { + name: "More", title: "More menu", - icon: `dots-horizontal`, - }, - settings: { - name: "Settings", + icon: `dots-horizontal`, + }, + settings: { + name: "Settings", title: "Settings menu", - icon: `cog`, - dependsOn: "more", - }, - reader: { - name: "Reader", + icon: `cog`, + dependsOn: "more", + }, + reader: { + name: "Reader", title: "Reader menu", - icon: `book-open-outline`, - dependsOn: "settings", - }, - advanced: { - name: "Advanced", + icon: `book-open-outline`, + dependsOn: "settings", + }, + advanced: { + name: "Advanced", title: "Advanced menu", - icon: `code-tags`, - dependsOn: "settings", - }, + icon: `code-tags`, + dependsOn: "settings", + }, }; function generateNavigationHtml(navKey) { - const navData = navigationMappings[navKey]; + const navData = navigationMappings[navKey]; - if (!navData) { - return "Unsupported Navigation!"; - } + if (!navData) { + return "Unsupported Navigation!"; + } - const { name, title, icon, dependsOn } = navData; + const { name, title, icon, dependsOn } = navData; - let html = `${icon}${name}`; + let html = `${icon}${name}`; - if (dependsOn) { - html = generateNavigationHtml(dependsOn) + ` → ` + html; - } + if (dependsOn) { + html = generateNavigationHtml(dependsOn) + ` → ` + html; + } - return html; + return html; } const shortcodes = { - nav: { - render: function (attrs, env) { - const { method, to } = attrs; - return generateNavigationHtml(to); - }, - }, + nav: { + render: function (attrs, env) { + const { method, to } = attrs; + return generateNavigationHtml(to); + }, + }, }; export default shortcodes; diff --git a/website/src/.vitepress/config/themeConfig.ts b/website/src/.vitepress/config/themeConfig.ts index 618f434a..176d3b57 100644 --- a/website/src/.vitepress/config/themeConfig.ts +++ b/website/src/.vitepress/config/themeConfig.ts @@ -38,7 +38,7 @@ const themeConfig: DefaultTheme.Config = { }, { icon: { - svg: '', + svg: '', }, link: "https://reddit.com/r/Tachiyomi", ariaLabel: "Support subreddit", diff --git a/website/src/.vitepress/theme/components/Changelogs.vue b/website/src/.vitepress/theme/components/Changelogs.vue index 2088f466..e8a14fcb 100644 --- a/website/src/.vitepress/theme/components/Changelogs.vue +++ b/website/src/.vitepress/theme/components/Changelogs.vue @@ -56,14 +56,14 @@ const dateFormatter = new Intl.DateTimeFormat("en", { diff --git a/website/src/.vitepress/theme/components/Contributors.vue b/website/src/.vitepress/theme/components/Contributors.vue index 39136c85..8f242ad5 100644 --- a/website/src/.vitepress/theme/components/Contributors.vue +++ b/website/src/.vitepress/theme/components/Contributors.vue @@ -81,29 +81,29 @@ function addToNonExistent(user: string) { diff --git a/website/src/.vitepress/theme/components/ExtensionGroup.vue b/website/src/.vitepress/theme/components/ExtensionGroup.vue deleted file mode 100644 index a4f891b3..00000000 --- a/website/src/.vitepress/theme/components/ExtensionGroup.vue +++ /dev/null @@ -1,50 +0,0 @@ - - - - - diff --git a/website/src/.vitepress/theme/components/Extensions/ExtensionItem.vue b/website/src/.vitepress/theme/components/Extensions/ExtensionItem.vue index 52615443..2431f2ae 100644 --- a/website/src/.vitepress/theme/components/Extensions/ExtensionItem.vue +++ b/website/src/.vitepress/theme/components/Extensions/ExtensionItem.vue @@ -77,7 +77,7 @@ export default { .extension-icon { flex-shrink: 0 - margin-left: -4px; + margin-left: -4px } .extension-text { @@ -129,7 +129,7 @@ export default { } @media (max-width 767px) { - padding: 0.4em 0em + padding: 0.4em 0 } } @@ -144,7 +144,7 @@ export default { padding: 0.5em .extension-icon { - margin-left: 0; + margin-left: 0 } .extension-download { diff --git a/website/src/.vitepress/theme/components/News.vue b/website/src/.vitepress/theme/components/News.vue index 03aa39d0..d682702d 100644 --- a/website/src/.vitepress/theme/components/News.vue +++ b/website/src/.vitepress/theme/components/News.vue @@ -33,14 +33,15 @@ const dateFormatter = new Intl.DateTimeFormat("en", { dateStyle: "medium" }); diff --git a/website/src/.vitepress/theme/components/OgImageTemplate.vue b/website/src/.vitepress/theme/components/OgImageTemplate.vue index 25a93378..c7c692ea 100644 --- a/website/src/.vitepress/theme/components/OgImageTemplate.vue +++ b/website/src/.vitepress/theme/components/OgImageTemplate.vue @@ -24,6 +24,6 @@
{{ description }}
-
+
diff --git a/website/src/.vitepress/theme/components/WhatsNew.vue b/website/src/.vitepress/theme/components/WhatsNew.vue index b86006ec..7e69cf2a 100644 --- a/website/src/.vitepress/theme/components/WhatsNew.vue +++ b/website/src/.vitepress/theme/components/WhatsNew.vue @@ -50,7 +50,7 @@ const whatsNew = computed(() => { transition: border-color 0.25s, background-color 0.25s padding: 24px height: 100% - margin: 1.5em auto 0.5em auto + margin: 1.5em auto 0.5em header { display: flex diff --git a/website/src/.vitepress/theme/data/changelogs.data.ts b/website/src/.vitepress/theme/data/changelogs.data.ts index fd465c3c..e389fc49 100644 --- a/website/src/.vitepress/theme/data/changelogs.data.ts +++ b/website/src/.vitepress/theme/data/changelogs.data.ts @@ -1,4 +1,4 @@ -import { defineLoader } from "vitepress" +import { defineLoader } from "vitepress"; import { Octokit } from "@octokit/rest"; import type { GetResponseDataTypeFromEndpointMethod } from "@octokit/types"; @@ -18,5 +18,5 @@ export default defineLoader({ }); return releases; - } + }, }); diff --git a/website/src/.vitepress/theme/data/news.data.ts b/website/src/.vitepress/theme/data/news.data.ts index 4c9b1629..c1b2fe34 100644 --- a/website/src/.vitepress/theme/data/news.data.ts +++ b/website/src/.vitepress/theme/data/news.data.ts @@ -1,4 +1,4 @@ -import { defineLoader, createContentLoader } from "vitepress" +import { defineLoader, createContentLoader } from "vitepress"; export interface News { title: string; @@ -16,12 +16,15 @@ export default defineLoader({ return articles .filter(({ url }) => url !== "/news/") - .map(({ frontmatter, url }) => ({ - title: frontmatter.title, - description: frontmatter.description, - date: frontmatter.date, - url, - })) + .map( + ({ frontmatter, url }) => + { + title: frontmatter.title, + description: frontmatter.description, + date: frontmatter.date, + url, + } + ) .sort((a, b) => b.date.localeCompare(a.date)); - } + }, }); diff --git a/website/src/.vitepress/theme/data/release.data.ts b/website/src/.vitepress/theme/data/release.data.ts index 831b5a0f..1011d12c 100644 --- a/website/src/.vitepress/theme/data/release.data.ts +++ b/website/src/.vitepress/theme/data/release.data.ts @@ -1,4 +1,4 @@ -import { defineLoader } from "vitepress" +import { defineLoader } from "vitepress"; import { Octokit } from "@octokit/rest"; import type { GetResponseDataTypeFromEndpointMethod } from "@octokit/types"; @@ -27,5 +27,5 @@ export default defineLoader({ }); return { stable, preview }; - } + }, }); diff --git a/website/src/.vitepress/theme/styles/base.styl b/website/src/.vitepress/theme/styles/base.styl index b89532d8..246b866b 100644 --- a/website/src/.vitepress/theme/styles/base.styl +++ b/website/src/.vitepress/theme/styles/base.styl @@ -117,13 +117,14 @@ html:not(.dark) { /** * Component: LocalSearch */ + .VPLocalSearchBox { - --vp-local-search-highlight-bg: var(--vp-c-brand-soft); - --vp-local-search-highlight-text: var(--vp-c-brand-dark); + --vp-local-search-highlight-bg: var(--vp-c-brand-soft) + --vp-local-search-highlight-text: var(--vp-c-brand-dark) } -.dark .VPLocalSearchBox { - --vp-local-search-highlight-text: var(--vp-c-brand-lightest); +.dark .VPLocalSearchBox { + --vp-local-search-highlight-text: var(--vp-c-brand-lightest) } /** @@ -191,6 +192,7 @@ main :where(h1, h2, h3, h4, h5, h6) + figure { /** * Component: Shortcodes * -------------------------------------------------------------------------- */ + .navigation { color: var(--vp-c-text-2) font-weight: 600 @@ -202,7 +204,7 @@ main :where(h1, h2, h3, h4, h5, h6) + figure { svg, span.name { - vertical-align: middle; /* Align both SVG and vertically */ + vertical-align: middle // Align both SVG and vertically } svg { diff --git a/website/src/.vitepress/theme/styles/forks/lint.styl b/website/src/.vitepress/theme/styles/forks/lint.styl new file mode 100644 index 00000000..a952baef --- /dev/null +++ b/website/src/.vitepress/theme/styles/forks/lint.styl @@ -0,0 +1,9 @@ +.extension-list { + > div { + &:not(:first-of-type) { + .extensions-total { + display: none + } + } + } +}