Skip to content

Commit c2e55b1

Browse files
committed
feat: Display a footer/list of npm packages per tool
Fix CorentinTh#1025
1 parent b430bae commit c2e55b1

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/layouts/tool.layout.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { useRoute } from 'vue-router';
33
import { useHead } from '@vueuse/head';
44
import type { HeadObject } from '@vueuse/head';
5+
import VueMarkdown from 'vue-markdown-render';
56
67
import BaseLayout from './base.layout.vue';
78
import FavoriteButton from '@/components/FavoriteButton.vue';
@@ -28,6 +29,19 @@ const { t } = useI18n();
2829
const i18nKey = computed<string>(() => route.path.trim().replace('/', ''));
2930
const toolTitle = computed<string>(() => t(`tools.${i18nKey.value}.title`, String(route.meta.name)));
3031
const toolDescription = computed<string>(() => t(`tools.${i18nKey.value}.description`, String(route.meta.description)));
32+
const toolFooter = computed<string>(() => {
33+
const createLink = (linkText: string, url: string) => {
34+
return `[${linkText.replace('[', '\\[').replace(']', '\\]')}](${url.replace('(', '%28').replace(')', '%29')})`;
35+
};
36+
const footer = t(`tools.${i18nKey.value}.footer`, String(route.meta.footer));
37+
const npmPackages = (route.meta.npmPackages as string[] || [])
38+
.map(
39+
packageName => createLink(
40+
packageName,
41+
packageName.includes('://') ? packageName : `https://www.npmjs.com/package/${packageName}`),
42+
);
43+
return ((npmPackages.length > 0 ? `Made with ${npmPackages.join(', ')}\n` : '') + footer).trim();
44+
});
3145
</script>
3246

3347
<template>
@@ -55,6 +69,10 @@ const toolDescription = computed<string>(() => t(`tools.${i18nKey.value}.descrip
5569
<div class="tool-content">
5670
<slot />
5771
</div>
72+
73+
<div class="tool-footer">
74+
<VueMarkdown :source="toolFooter" />
75+
</div>
5876
</BaseLayout>
5977
</template>
6078

@@ -66,9 +84,11 @@ const toolDescription = computed<string>(() => t(`tools.${i18nKey.value}.descrip
6684
align-items: flex-start;
6785
flex-wrap: wrap;
6886
gap: 16px;
87+
overflow-x: auto;
6988
7089
::v-deep(& > *) {
7190
flex: 0 1 600px;
91+
min-width:0;
7292
}
7393
}
7494
@@ -104,5 +124,9 @@ const toolDescription = computed<string>(() => t(`tools.${i18nKey.value}.descrip
104124
opacity: 0.7;
105125
}
106126
}
127+
.tool-footer {
128+
opacity: 0.7;
129+
font-size: 12px;
130+
}
107131
}
108132
</style>

src/tools/tools.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export interface Tool {
1010
redirectFrom?: string[]
1111
isNew: boolean
1212
createdAt?: Date
13+
npmPackages?: string[]
14+
footer?: string
1315
}
1416

1517
export interface ToolCategory {

0 commit comments

Comments
 (0)