diff --git a/app/api.ts b/app/api.ts
index 78188b8..26606f6 100644
--- a/app/api.ts
+++ b/app/api.ts
@@ -1,7 +1,16 @@
export type DJAPIEndpoint = "/rp-articles";
+type RPArticle = {
+ title: string,
+ slug: string;
+ titleDe: string,
+ titleEn: string,
+ author: string,
+ tags?: string[],
+};
+
export interface DJAPIResultMap extends Record {
- "/rp-articles": { slug: string; title: string, tags?: string[] }[];
+ "/rp-articles": RPArticle[];
}
export type DJAPIResult = DJAPIResultMap[DJAPIEndpoint];
diff --git a/app/generative-energy/GEDeutsch.tsx b/app/generative-energy/GEDeutsch.tsx
index a7beab6..93aaa2a 100644
--- a/app/generative-energy/GEDeutsch.tsx
+++ b/app/generative-energy/GEDeutsch.tsx
@@ -31,7 +31,7 @@ export default defineComponent({
{rpArticles.value && rpArticles.value.map((_) => (
- {_.title}
+ {_.titleDe}
{_.tags?.map(tag => {tag})}
diff --git a/app/generative-energy/GEDeutschArticle.tsx b/app/generative-energy/GEDeutschArticle.tsx
index 90bed3d..0189902 100644
--- a/app/generative-energy/GEDeutschArticle.tsx
+++ b/app/generative-energy/GEDeutschArticle.tsx
@@ -41,7 +41,13 @@ export default defineComponent({
const articleMetadata = computed(() => articleData.value?.find(_ => _.slug === props.articleName));
- useHead({ title: () => articleMetadata.value?.title ?? '' });
+ useHead({
+ title: () => articleMetadata.value?.title ?? '',
+ metatags: () => articleMetadata.value ? [
+ { name: 'title', content: articleMetadata.value.title },
+ { name: 'author', content: articleMetadata.value.author },
+ ] : [],
+ });
function transformArticleNode(node: Node): VNode | string {
if (node.nodeType === node.ELEMENT_NODE) {
@@ -49,6 +55,10 @@ export default defineComponent({
const attrs: Record = {};
const children = [...node.childNodes].map((_) => transformArticleNode(_));
+ if (el.attributes.getNamedItem('lang')?.value === 'en') {
+ el.ariaHidden = 'true';
+ }
+
if (el.tagName === "P") {
(el as HTMLParagraphElement).dataset.tunit = '';
}
@@ -101,7 +111,7 @@ export default defineComponent({
Bei dem untenstehenden Artikel handelt es sich um eine hobbymäßige, amateurhafte Übersetzung des
- Artikels „{ articleMetadata.value?.title }“ von Ray Peat. Bei Ungenauigkeiten oder Fehlübersetzungen freue ich mich über eine Mail!
+ Artikels „{ articleMetadata.value?.titleEn }“ von Ray Peat. Bei Ungenauigkeiten oder Fehlübersetzungen freue ich mich über eine Mail!
{ articleMetadata.value?.tags?.includes('in-arbeit') && 🚧 Bitte beachte, dass diese Übersetzung noch in Arbeit ist! 🚧
}
diff --git a/app/generative-energy/GEMain.tsx b/app/generative-energy/GEMain.tsx
index 5411d41..c759673 100644
--- a/app/generative-energy/GEMain.tsx
+++ b/app/generative-energy/GEMain.tsx
@@ -17,8 +17,8 @@ export default {
and my life in general. Hover over the links below for more detail.
+ Links
-
Links
-
diff --git a/app/home/DJHomeRoot.tsx b/app/home/DJHomeRoot.tsx
index b9bcd2c..726eb02 100644
--- a/app/home/DJHomeRoot.tsx
+++ b/app/home/DJHomeRoot.tsx
@@ -71,7 +71,7 @@ export default defineComponent({
stations, as well as the main municipalities, into English. You live in Allach? It's
Axleigh now. Giesing? Nope! Kyesing! This is a WIP.
">
- München auf Englisch - Munich in English
+ München auf Englisch - Munich in English
diff --git a/app/useDJSSRContext.ts b/app/useDJSSRContext.ts
index 36abcec..10ae13b 100644
--- a/app/useDJSSRContext.ts
+++ b/app/useDJSSRContext.ts
@@ -3,6 +3,7 @@ import { type MaybeRefOrGetter, useSSRContext } from "vue";
export type DJSSRContext = {
head: {
title: MaybeRefOrGetter;
+ metatags: MaybeRefOrGetter>;
};
registry: Record;
styles: Record;
diff --git a/app/useHead.ts b/app/useHead.ts
index 3970ed8..2131dba 100644
--- a/app/useHead.ts
+++ b/app/useHead.ts
@@ -1,19 +1,37 @@
-import { watchEffect, toValue, type MaybeRefOrGetter } from 'vue';
+import { watch, toValue, type MaybeRefOrGetter } from 'vue';
import useDJSSRContext from "@/useDJSSRContext.ts";
+import { h } from "@/util.ts";
export default function useHead(params: {
title: MaybeRefOrGetter,
+ metatags?: MaybeRefOrGetter>
}) {
const context = useDJSSRContext();
if (context) {
context.head.title = params.title;
+ context.head.metatags = params.metatags ?? [];
} else {
- watchEffect(() => {
- const newTitle = toValue(params.title);
+ watch([() => toValue(params.title), () => toValue(params.metatags) ?? []], ([newTitle, newMetatags]) => {
if (newTitle) {
document.title = newTitle;
}
- });
+ const currMetatags = document.head.querySelectorAll('meta');
+ const existing = new Set();
+ for (const currMetatag of currMetatags) {
+ const match = newMetatags.find(_ => _.name === currMetatag.name);
+ if (!match) {
+ currMetatag.remove();
+ } else {
+ existing.add(match.name);
+ currMetatag.content = match.content;
+ }
+ }
+ for (const newMetatag of newMetatags) {
+ if (!existing.has(newMetatag.name)) {
+ document.head.appendChild(h('meta', newMetatag));
+ }
+ }
+ }, { immediate: true });
}
}
diff --git a/main.ts b/main.ts
index 683d582..735102a 100644
--- a/main.ts
+++ b/main.ts
@@ -15,7 +15,10 @@ const utf8Decoder = new TextDecoder("utf-8");
const parser = new DOMParser();
function appHeaderScript(params: { ssrContext: DJSSRContext, entryPath: string }) {
- return `