From 0f504aa51afdff9b1fe62cd7c2730cb33de370a7 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Sat, 15 Jul 2023 17:32:48 +0900 Subject: [PATCH] (fix) docs: broken types, broken components --- assets/css/tailwind.css | 10 ++++++++- assets/js/misc/index.ts | 27 ++++++++++++++++++++++++ components/content/MfmPreview.vue | 3 ++- components/content/MkIndex.vue | 15 +++++++++++--- components/content/ProseA.vue | 2 +- components/content/ProseImg.vue | 34 +++++++++++++++++++++++++++++++ components/mk/Mfm.ts | 6 +++--- nuxt.config.ts | 2 +- 8 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 components/content/ProseImg.vue diff --git a/assets/css/tailwind.css b/assets/css/tailwind.css index c7480251..e2f1cdd2 100644 --- a/assets/css/tailwind.css +++ b/assets/css/tailwind.css @@ -133,11 +133,19 @@ html.light .markdown-body { .markdown-body h4 > a[href^='#'], .markdown-body h5 > a[href^='#'], .markdown-body h6 > a[href^='#'] { - all: unset; color: var(--color-fg-default); cursor: pointer; } +.markdown-body h1 > a[href^='#']:hover, +.markdown-body h2 > a[href^='#']:hover, +.markdown-body h3 > a[href^='#']:hover, +.markdown-body h4 > a[href^='#']:hover, +.markdown-body h5 > a[href^='#']:hover, +.markdown-body h6 > a[href^='#']:hover { + text-decoration: none; +} + .markdown-body ul { list-style: disc; } diff --git a/assets/js/misc/index.ts b/assets/js/misc/index.ts index 515ada6a..8cf5c7af 100644 --- a/assets/js/misc/index.ts +++ b/assets/js/misc/index.ts @@ -11,4 +11,31 @@ export function resolveObjPath(o: object, s: string): any { } } return o; +} + +export function isLocalPath(link: string, base?: string): boolean { + let baseUrl; + if (base) { + baseUrl = base; + } else { + const runtimeConfig = useRuntimeConfig(); + baseUrl = runtimeConfig.public.baseUrl; + } + const rootDomain = new URL(baseUrl); + try { + const url = new URL(link); + if (!url.hostname || rootDomain.hostname === url.hostname) { + return true; + } else if (rootDomain.hostname !== url.hostname) { + return false; + } + return false; + } catch(error) { + if(link !== '') { + return true; + } else { + throw error; + } + } + } \ No newline at end of file diff --git a/components/content/MfmPreview.vue b/components/content/MfmPreview.vue index 56ed7e4b..f54b7a3e 100644 --- a/components/content/MfmPreview.vue +++ b/components/content/MfmPreview.vue @@ -1,5 +1,6 @@ diff --git a/components/content/MkIndex.vue b/components/content/MkIndex.vue index e12f0700..b8c45a54 100644 --- a/components/content/MkIndex.vue +++ b/components/content/MkIndex.vue @@ -7,10 +7,10 @@ :key="item._path" :to="localePath(item._path)" > -

+

{{ item.navTitle || item.title }}

-

+

{{ item.description ?? "" }}

@@ -61,4 +61,13 @@ const findDeepObject = (obj: Record, condition: (v: any) => boolean const query = queryContent(realBasePath.value); - \ No newline at end of file + \ No newline at end of file diff --git a/components/content/ProseA.vue b/components/content/ProseA.vue index c1c592f7..0080af8b 100644 --- a/components/content/ProseA.vue +++ b/components/content/ProseA.vue @@ -14,7 +14,7 @@ const props = defineProps({ type: String, default: undefined, required: false - } + }, }) let realHref = props.href; diff --git a/components/content/ProseImg.vue b/components/content/ProseImg.vue new file mode 100644 index 00000000..2ea9d4e0 --- /dev/null +++ b/components/content/ProseImg.vue @@ -0,0 +1,34 @@ + + + diff --git a/components/mk/Mfm.ts b/components/mk/Mfm.ts index b3594342..840e15de 100644 --- a/components/mk/Mfm.ts +++ b/components/mk/Mfm.ts @@ -9,8 +9,8 @@ const QUOTE_STYLE = ` display: block; margin: 8px; padding: 6px 0 6px 12px; -color: var(--fg); -border-left: solid 3px var(--fg); +color: currentColor; +border-left: solid 3px currentColor; opacity: 0.7; `.split('\n').join(' '); @@ -231,7 +231,7 @@ export default function(props: { } case 'link': { - return [h(NuxtLink, { + return [h(ProseAVue, { key: Math.random(), to: token.props.url, rel: 'nofollow noopener', diff --git a/nuxt.config.ts b/nuxt.config.ts index 5d511861..b126b9d9 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -44,10 +44,10 @@ export default defineNuxtConfig({ }, }, content: { - //sources: Object.fromEntries(locales.map((e) => [e.code, { driver: 'fs', prefix: `/${e.code}`, base: resolve(__dirname, `content/${e.iso}`), }])), navigation: { fields: [ 'date', + 'description', ] } },