From c2e55b1a3f624371ee70d6688dbaa38bbc2f8d3b Mon Sep 17 00:00:00 2001 From: sharevb Date: Tue, 25 Jun 2024 09:10:28 +0200 Subject: [PATCH] feat: Display a footer/list of npm packages per tool Fix #1025 --- src/layouts/tool.layout.vue | 24 ++++++++++++++++++++++++ src/tools/tools.types.ts | 2 ++ 2 files changed, 26 insertions(+) diff --git a/src/layouts/tool.layout.vue b/src/layouts/tool.layout.vue index aa808f1c..38c8c930 100644 --- a/src/layouts/tool.layout.vue +++ b/src/layouts/tool.layout.vue @@ -2,6 +2,7 @@ import { useRoute } from 'vue-router'; import { useHead } from '@vueuse/head'; import type { HeadObject } from '@vueuse/head'; +import VueMarkdown from 'vue-markdown-render'; import BaseLayout from './base.layout.vue'; import FavoriteButton from '@/components/FavoriteButton.vue'; @@ -28,6 +29,19 @@ const { t } = useI18n(); const i18nKey = computed(() => route.path.trim().replace('/', '')); const toolTitle = computed(() => t(`tools.${i18nKey.value}.title`, String(route.meta.name))); const toolDescription = computed(() => t(`tools.${i18nKey.value}.description`, String(route.meta.description))); +const toolFooter = computed(() => { + const createLink = (linkText: string, url: string) => { + return `[${linkText.replace('[', '\\[').replace(']', '\\]')}](${url.replace('(', '%28').replace(')', '%29')})`; + }; + const footer = t(`tools.${i18nKey.value}.footer`, String(route.meta.footer)); + const npmPackages = (route.meta.npmPackages as string[] || []) + .map( + packageName => createLink( + packageName, + packageName.includes('://') ? packageName : `https://www.npmjs.com/package/${packageName}`), + ); + return ((npmPackages.length > 0 ? `Made with ${npmPackages.join(', ')}\n` : '') + footer).trim(); +}); @@ -66,9 +84,11 @@ const toolDescription = computed(() => t(`tools.${i18nKey.value}.descrip align-items: flex-start; flex-wrap: wrap; gap: 16px; + overflow-x: auto; ::v-deep(& > *) { flex: 0 1 600px; + min-width:0; } } @@ -104,5 +124,9 @@ const toolDescription = computed(() => t(`tools.${i18nKey.value}.descrip opacity: 0.7; } } + .tool-footer { + opacity: 0.7; + font-size: 12px; + } } diff --git a/src/tools/tools.types.ts b/src/tools/tools.types.ts index dcef8543..a38ff135 100644 --- a/src/tools/tools.types.ts +++ b/src/tools/tools.types.ts @@ -10,6 +10,8 @@ export interface Tool { redirectFrom?: string[] isNew: boolean createdAt?: Date + npmPackages?: string[] + footer?: string } export interface ToolCategory {