-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show license information at
/license-information
Show license information of the used open source software on `/license-information`.
- Loading branch information
Showing
5 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"nuxt-bundle": { | ||
"license-information": { | ||
"description": "Diese Webseite basiert auf Free Open Source Software (FOSS), die gesonderten Lizenzbedingungen unterliegen, die im folgenden aufgelistet werden.", | ||
"title": "Lizenzinformationen" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"nuxt-bundle": { | ||
"license-information": { | ||
"description": "This website is based on Free Open Source Software (FOSS), which is subject to separate license conditions, which are listed below.", | ||
"title": "License information" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<template> | ||
<v-container class="full-width"> | ||
<p class="text-h4"> | ||
{{ i18n.t("nuxt-bundle.license-information.title") }} | ||
</p> | ||
<p class="text-body-1"> | ||
{{ i18n.t("nuxt-bundle.license-information.description") }} | ||
</p> | ||
<v-row v-if="pending"> | ||
<v-col v-for="index in 12" :key="index" cols="12" md="6" lg="4" xl="3"> | ||
<v-skeleton-loader type="article"></v-skeleton-loader> | ||
</v-col> | ||
</v-row> | ||
<v-row v-else> | ||
<client-only> | ||
<v-col | ||
v-for="license of softwareInfo()" | ||
:key="license.name" | ||
cols="12" | ||
md="6" | ||
lg="4" | ||
xl="3" | ||
> | ||
<c-license-card :software-info="license"></c-license-card> | ||
</v-col> | ||
</client-only> | ||
</v-row> | ||
</v-container> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { type Composer } from "vue-i18n"; | ||
const i18n: Composer = useI18n(); | ||
// As nuxt can't fetch data from the public dir during SSR, the request can only be made on client side (see also nuxt/nuxt#13857). | ||
const { pending, data: licenses } = await useFetch< | ||
{ | ||
name: string; | ||
version: string; | ||
author: { name: string } | null; | ||
license: string; | ||
licenseText: string | null; | ||
repository: { url: string } | string | null; | ||
}[] | ||
>("/dependencies.json", { | ||
lazy: true, | ||
server: false, | ||
}); | ||
function softwareInfo() { | ||
if (!licenses.value) return null; | ||
return licenses.value | ||
.sort((a, b) => a.name.localeCompare(b.name)) | ||
.map((license) => { | ||
let repositoryLink: string | undefined = | ||
typeof license.repository === "string" | ||
? license.repository | ||
: license.repository?.url; | ||
let repositoryOwner: string | undefined; | ||
if (repositoryLink) { | ||
// Normalize github URL: | ||
// 1. Remove `[...]github.com` prefix with protocol etc., if present. | ||
// 2. Remove `.git` suffix, if present. | ||
const repositoryCoordinates = repositoryLink | ||
.replace(/.+?(github.com\/)/, "") | ||
.replace(".git", ""); | ||
// 3. Prepend `https://github.com/`. | ||
repositoryLink = "https://github.com/" + repositoryCoordinates; | ||
// If author is not set, retrieve author from repository coordinates. | ||
if (!license.author) | ||
repositoryOwner = repositoryCoordinates.split("/")[0]; | ||
} | ||
return { | ||
name: license.name, | ||
version: license.version, | ||
author: license.author?.name ?? repositoryOwner, | ||
notice: license.licenseText ?? license.license, | ||
repositoryLink, | ||
}; | ||
}); | ||
} | ||
useHead({ | ||
title: i18n.t("nuxt-bundle.license-information.title"), | ||
}); | ||
useSeoMeta({ | ||
title: i18n.t("nuxt-bundle.license-information.title"), | ||
ogTitle: i18n.t("nuxt-bundle.license-information.title"), | ||
description: i18n.t("nuxt-bundle.license-information.description"), | ||
ogDescription: i18n.t("nuxt-bundle.license-information.description"), | ||
}); | ||
</script> | ||
|
||
<style lang="scss"></style> |