Skip to content

Commit

Permalink
chore: formatting and housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
taskylizard committed Aug 28, 2024
1 parent 9d6f121 commit 934ebcf
Show file tree
Hide file tree
Showing 36 changed files with 272 additions and 499 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
**/*.md
pnpm-lock.yaml
.turbo
.cache
14 changes: 14 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,17 @@ htmlWhitespaceSensitivity: ignore
plugins:
- prettier-plugin-tailwindcss
- prettier-plugin-pkgsort
- '@ianvs/prettier-plugin-sort-imports'

importOrder:
[
'',
'<TYPES>^(node:)',
'<TYPES>',
'<TYPES>^[.]',
'<BUILTIN_MODULES>',
'<THIRD_PARTY_MODULES>',
'^[.]',
'^(?!.*[.]css$)[./].*$',
'.css$'
]
3 changes: 3 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is the API for the website and other related services.

Licensed under the Apache License v2.0, see [LICENSE](../docs/.vitepress/LICENSE) for more information.
29 changes: 15 additions & 14 deletions api/middleware/cors.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/**
* Copyright (c) taskylizard. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) taskylizard. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { corsEventHandler } from 'nitro-cors'

export default corsEventHandler(
Expand Down
29 changes: 15 additions & 14 deletions api/routes/feedback.post.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/**
* Copyright (c) taskylizard. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) taskylizard. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { fetcher } from 'itty-fetcher'
import {
FeedbackSchema,
Expand Down
28 changes: 14 additions & 14 deletions api/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* Copyright (c) taskylizard. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) taskylizard. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default eventHandler(() => {
return { nitro: 'works' }
})
29 changes: 15 additions & 14 deletions api/routes/single-page.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/**
* Copyright (c) taskylizard. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) taskylizard. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { fetcher } from 'itty-fetcher'

// Look inside tbe docs directory
Expand Down
4 changes: 2 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"extends": ["@taskylizard/biome-config", "./docs/.vitepress/.imports.json"],
"extends": ["@taskylizard/biome-config", "./.cache/imports.json"],
"files": {
"ignore": [
"docs/.vitepress/**/*.vue",
"docs/.vitepress/vue-shim.d.ts",
"docs/.vitepress/imports.d.ts"
".cache/imports.d.ts"
]
},
"formatter": {
Expand Down
73 changes: 0 additions & 73 deletions docs/.vitepress/.imports.json

This file was deleted.

8 changes: 4 additions & 4 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import consola from 'consola'
import UnoCSS from 'unocss/vite'
import AutoImport from 'unplugin-auto-import/vite'
import { defineConfig } from 'vitepress'
import {
commitRef,
Expand All @@ -11,10 +12,9 @@ import {
} from './constants'
import { generateFeed, generateImages, generateMeta } from './hooks'
import { defs, emojiRender, movePlugin } from './markdown/emoji'
import { toggleStarredPlugin } from './markdown/toggleStarred'
import { headersPlugin } from './markdown/headers'
import { toggleStarredPlugin } from './markdown/toggleStarred'
import { transforms } from './transformer'
import AutoImport from 'unplugin-auto-import/vite'

// @unocss-include

Expand Down Expand Up @@ -59,12 +59,12 @@ export default defineConfig({
configFile: '../unocss.config.ts'
}),
AutoImport({
dts: './.vitepress/imports.d.ts',
dts: '../.cache/imports.d.ts',
imports: ['vue', 'vitepress'],
vueTemplate: true,
biomelintrc: {
enabled: true,
filepath: './docs/.vitepress/.imports.json'
filepath: './.cache/imports.json'
}
}),
transforms(),
Expand Down
41 changes: 20 additions & 21 deletions docs/.vitepress/constants.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/**
* Copyright (c) taskylizard. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) taskylizard. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { DefaultTheme } from 'vitepress'
import { transform, transformGuide } from './transformer'

// @unocss-include

export const meta = {
Expand All @@ -26,8 +28,9 @@ 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>`
Expand Down Expand Up @@ -82,11 +85,7 @@ export const search: DefaultTheme.Config['search'] = {
combineWith: 'AND',
fuzzy: true,
// @ts-ignore
boostDocument: (
documentId,
term,
storedFields: Record<string, string | string[]>
) => {
boostDocument: (documentId, term, storedFields: Record) => {
const titles = (storedFields?.titles as string[])
.filter((t) => Boolean(t))
.map((t) => t.toLowerCase())
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/hooks/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { HeadConfig, TransformContext } from 'vitepress'

export function generateMeta(context: TransformContext, hostname: string) {
Expand Down
12 changes: 7 additions & 5 deletions docs/.vitepress/hooks/opengraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { ContentData, SiteConfig } from 'vitepress'
import type { SatoriOptions } from 'x-satori/vue'
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 { createContentLoader } from 'vitepress'
import { satoriVue } from 'x-satori/vue'
import { headers } from '../transformer/constants'

const __dirname = dirname(fileURLToPath(import.meta.url))
Expand Down Expand Up @@ -86,14 +88,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
Expand Down
Loading

0 comments on commit 934ebcf

Please sign in to comment.