Skip to content

Commit

Permalink
chore: cleanup [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Aug 17, 2023
1 parent 51b24e3 commit f8a8b60
Show file tree
Hide file tree
Showing 39 changed files with 1,221 additions and 1,143 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ dist
# environment variables
.env
.env.*

# tests
/e2e/
/tests/
3 changes: 2 additions & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
- name: Checkout respository
uses: actions/checkout@v3

# necessary because `actions/setup-node` does not yet support `corepack`.
# @see https://github.com/actions/setup-node/issues/531
Expand Down
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ engine-strict=true
# @see https://github.com/nuxt/nuxt/issues/14146
shamefully-hoist=true
shell-emulator=true
use-node-version=18.16.0
use-node-version=18.17.1
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"lokalise.i18n-ally",
"mikestead.dotenv",
"ms-playwright.playwright",
"stylelint.vscode-stylelint",
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
},
"files.eol": "\n",
"html.autoCreateQuotes": false,
"i18n-ally.keepFulfilled": true,
"i18n-ally.keystyle": "nested",
"i18n-ally.localesPaths": ["./messages"],
"i18n-ally.sortKeys": true,
"i18n-ally.tabStyle": "tab",
"less.validate": false,
"scss.validate": false,
"stylelint.enable": true,
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ COPY --chown=node:node .npmrc package.json pnpm-lock.yaml ./

RUN pnpm fetch

COPY --chown=node:node nuxt.config.ts tailwind.config.js tsconfig.json ./
COPY --chown=node:node config ./config
COPY --chown=node:node public ./public
COPY --chown=node:node src ./src
COPY --chown=node:node ./ ./

ARG NUXT_PUBLIC_APP_BASE_URL
ARG NUXT_PUBLIC_REDMINE_ID
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/components/app-footer.vue → components/app-footer.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<script lang="ts" setup>
import { type NavLinkProps } from "@/components/nav-link.vue";
const t = useTranslations("AppFooter");
const t = useTranslations();
const links = {
imprint: { href: { path: "/imprint" }, label: t("links.imprint") },
imprint: { href: { path: "/imprint" }, label: t("AppFooter.links.imprint") },
} satisfies Record<string, { href: NavLinkProps["href"]; label: string }>;
</script>

<template>
<footer class="border-t border-neutral-200">
<div class="container flex items-center justify-between gap-4 py-8">
<nav :aria-label="t('navigation-secondary')">
<nav :aria-label="t('AppFooter.navigation-secondary')">
<ul class="flex items-center gap-4" role="list">
<li v-for="(link, key) of links" :key="key">
<NavLink :href="link.href">
Expand Down
6 changes: 3 additions & 3 deletions src/components/app-header.vue → components/app-header.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<script lang="ts" setup>
import { type NavLinkProps } from "@/components/nav-link.vue";
const t = useTranslations("AppHeader");
const t = useTranslations();
const links = {
home: { href: { path: "/" }, label: t("links.home") },
home: { href: { path: "/" }, label: t("AppHeader.links.home") },
} satisfies Record<string, { href: NavLinkProps["href"]; label: string }>;
</script>

<template>
<header class="border-b border-neutral-200">
<div class="container flex items-center justify-between gap-4 py-8">
<nav :aria-label="t('navigation-main')">
<nav :aria-label="t('AppHeader.navigation-main')">
<ul class="flex items-center gap-4" role="list">
<li v-for="(link, key) of links" :key="key">
<NavLink :href="link.href">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ const imprint = await useFetch(String(createImprintUrl(locale.value, redmineId))

<template>
<!-- eslint-disable-next-line vue/no-v-html -->
<div class="prose" v-html="imprint.data.value" />
<div v-if="imprint.data.value" class="prose" v-html="imprint.data.value" />
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { locales } from "@/config/i18n.config";
const currentLocale = useLocale();
const t = useTranslations("LocaleSwitcher");
const t = useTranslations();
const switchLocalePath = useSwitchLocalePath();
</script>

Expand All @@ -13,13 +13,13 @@ const switchLocalePath = useSwitchLocalePath();

<NuxtLink v-if="locale !== currentLocale" :href="{ path: switchLocalePath(locale) }">
<span class="sr-only">
{{ t("switch-locale", { locale: t(`locales.${locale}`) }) }}
{{ t("LocaleSwitcher.switch-locale", { locale: t(`locales.${locale}`) }) }}
</span>
<span aria-hidden="true">{{ locale.toUpperCase() }}</span>
</NuxtLink>
<span v-else>
<span class="sr-only">
{{ t("current-locale", { locale: t(`locales.${locale}`) }) }}
{{ t("LocaleSwitcher.current-locale", { locale: t(`locales.${locale}`) }) }}
</span>
<span aria-hidden="true">{{ locale.toUpperCase() }}</span>
</span>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const router = useRouter();
const message = ref("");
function onChangeMessaqge(to: RouteLocationNormalized) {
function onChangeMessaqe(to: RouteLocationNormalized) {
if (typeof to.meta.title === "string") {
message.value = to.meta.title;
} else {
Expand Down Expand Up @@ -33,7 +33,7 @@ function onChangeMessaqge(to: RouteLocationNormalized) {
router.afterEach((to, from) => {
if (to.path !== from.path) {
onChangeMessaqge(to);
onChangeMessaqe(to);
}
trackPageView(to, from);
Expand Down
2 changes: 1 addition & 1 deletion src/components/skip-link.vue → components/skip-link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function onClick() {

<template>
<NuxtLink
class="fixed -translate-y-full rounded bg-neutral-50 px-4 py-3 text-neutral-900 transition focus:translate-y-0"
class="rounded fixed -translate-y-full bg-neutral-50 px-4 py-3 text-neutral-900 transition focus:translate-y-0"
:href="{ hash: `#${props.targetId}` }"
@click="onClick"
>
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions composables/use-translations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { type Locale, type Schema } from "@/config/i18n.config";

export function useTranslations() {
const { t } = useI18n<Schema, Locale>();

return t;
}
6 changes: 4 additions & 2 deletions src/config/i18n.config.ts → config/i18n.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type messages from "@/messages/de.json";

export const locales = {
de: { code: "de", iso: "de-AT", file: "de.json" },
en: { code: "en", iso: "en-US", file: "en.json" },
en: { code: "en", iso: "en-GB", file: "en.json" },
} satisfies Record<string, LocaleObject>;

export type Locale = keyof typeof locales;
Expand All @@ -13,4 +13,6 @@ export const defaultLocale: Locale = "en";

export type Messages = typeof messages;

export type Schema = { message: Messages };
export interface Schema {
message: Messages;
}
File renamed without changes.
10 changes: 5 additions & 5 deletions src/error.vue → error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defineProps<{
error: Error;
}>();
const t = useTranslations("ErrorPage");
const t = useTranslations();
const localePath = useLocalePath();
useSeoMeta({
Expand All @@ -23,13 +23,13 @@ useSeoMeta({
});
function onReset() {
clearError({ redirect: localePath("/") });
void clearError({ redirect: localePath("/") });
}
</script>

<template>
<MainContent>
<h1>{{ t("title") }}</h1>
<button @click="onReset">{{ t("try-again") }}</button>
<MainContent class="grid min-h-full place-items-center">
<h1>{{ t("ErrorPage.title") }}</h1>
<button @click="onReset">{{ t("ErrorPage.try-again") }}</button>
</MainContent>
</template>
21 changes: 10 additions & 11 deletions src/layouts/default.vue → layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { type WebSite, type WithContext } from "schema-dts";
const env = useRuntimeConfig();
const locale = useLocale();
const t = useTranslations("DefaultLayout");
const translate = useTranslations();
const t = useTranslations();
const route = useRoute();
const i18nHead = useLocaleHead({
Expand All @@ -22,10 +21,10 @@ useHead({
}),
},
titleTemplate: computed(() => {
return ["%s", t("meta.title")].join(" | ");
return ["%s", t("DefaultLayout.meta.title")].join(" | ");
}),
title: computed(() => {
return translate(route.meta.title);
return t(route.meta.title);
}),
link: computed(() => {
return [
Expand All @@ -37,11 +36,11 @@ useHead({
}),
meta: computed(() => {
return [
{ name: "description", content: t("meta.description") },
{ name: "description", content: t("DefaultLayout.meta.description") },
{ property: "og:type", content: "website" },
{ property: "og:title", content: translate(route.meta.title) },
{ property: "og:site_name", content: t("meta.title") },
{ property: "og:description", content: t("meta.description") },
{ property: "og:title", content: t(route.meta.title) },
{ property: "og:site_name", content: t("DefaultLayout.meta.title") },
{ property: "og:description", content: t("DefaultLayout.meta.description") },
{ property: "og:image", content: "/opengraph-image.png" },
{ property: "og:locale", content: locale.value },
...(i18nHead.value.meta ?? []),
Expand All @@ -51,8 +50,8 @@ useHead({
const jsonLd: WithContext<WebSite> = {
"@context": "https://schema.org",
"@type": "WebSite",
name: t("meta.title"),
description: t("meta.description"),
name: t("DefaultLayout.meta.title"),
description: t("DefaultLayout.meta.description"),
};
const scripts = [
Expand All @@ -79,7 +78,7 @@ useHead({

<template>
<div class="grid min-h-full grid-rows-[auto_1fr_auto] bg-neutral-50 font-body text-neutral-900">
<SkipLink target-id="main-content">{{ t("skip-to-main-content") }}</SkipLink>
<SkipLink target-id="main-content">{{ t("DefaultLayout.skip-to-main-content") }}</SkipLink>

<AppHeader />
<slot />
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/messages/en.json → messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"DefaultLayout": {
"meta": {
"title": "ACDH-CH App",
"description": ""
"description": "ACDH-CH App"
},
"skip-to-main-content": "Skip to main content"
},
Expand Down
12 changes: 3 additions & 9 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { fileURLToPath } from "node:url";

import { defaultLocale, locales } from "./src/config/i18n.config";
import { defaultLocale, locales } from "./config/i18n.config";

export default defineNuxtConfig({
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
"~": fileURLToPath(new URL("./", import.meta.url)),
"@": fileURLToPath(new URL("./", import.meta.url)),
},
components: [{ path: "@/components", pathPrefix: false }],
content: {
Expand All @@ -17,9 +16,6 @@ export default defineNuxtConfig({
devtools: {
enabled: true,
},
dir: {
public: "../public",
},
experimental: {
componentIslands: true,
},
Expand Down Expand Up @@ -60,16 +56,14 @@ export default defineNuxtConfig({
NUXT_PUBLIC_REDMINE_ID: process.env.NUXT_PUBLIC_REDMINE_ID,
},
},
srcDir: "./src/",
typescript: {
shim: false,
strict: true,
// https://github.com/nuxt/nuxt/issues/14816#issuecomment-1484918081
tsConfig: {
compilerOptions: {
paths: {
"@/*": ["./src/*"],
"~/*": ["./*"],
"@/*": ["./*"],
},
},
},
Expand Down
Loading

0 comments on commit f8a8b60

Please sign in to comment.