Dodanie Title i Description strony do yamli oraz jezeli nie ma seo to do strony

This commit is contained in:
dm
2025-12-21 17:24:09 +01:00
parent e9f440353d
commit 259ee007db
9 changed files with 63 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
# tytuł dokumentu jednoczesnie tytułem strony <title></title>
title: "Polityka Prywatności" title: "Polityka Prywatności"
# opis wstawiany w <meta name="description" content=""
description: Polityka prywatności, opisuje zasady ochrony Twoich danych osobowych.
visible: true visible: true
intro: Polityka prywatności, opisuje zasady ochrony Twoich danych osobowych.
content: | content: |
## §1. Informacje podstawowe. ## §1. Informacje podstawowe.

View File

@@ -1,6 +1,6 @@
title: "Promocja świąteczna" title: "Promocja świąteczna"
description: Przykładowo gdybysmy dodali promocję do dokumentów
visible: true visible: true
intro: Przykładowo gdybysmy dodali promocję do dokumentów
content: | content: |
Jeśli kupujesz w sklepach internetowych, prawdopodobnie co pewien czas natykasz się na opisy, które nie zachęcają do zakupów. Jeśli kupujesz w sklepach internetowych, prawdopodobnie co pewien czas natykasz się na opisy, które nie zachęcają do zakupów.
Do najczęściej powtarzanych błędów opisów produktów należą: Do najczęściej powtarzanych błędów opisów produktów należą:

View File

@@ -1,3 +1,5 @@
title: Możliwości telewizji JAMBOX
description: Funkcje i udogodnienia dostępne w JAMBOX.
sections: sections:
- title: CatchUp - Archiwum TV - title: CatchUp - Archiwum TV
image: https://www.jambox.pl/sites/default/files/jambox-kyanit-catchup1.png image: https://www.jambox.pl/sites/default/files/jambox-kyanit-catchup1.png

View File

@@ -46,6 +46,7 @@ export default function JamboxMozliwosciSearch({ items = [] }) {
<div className="f-chsearch__top"> <div className="f-chsearch__top">
<div className="f-chsearch__inputwrap"> <div className="f-chsearch__inputwrap">
<input <input
name="search"
className="f-chsearch__input" className="f-chsearch__input"
type="search" type="search"
value={search.query} value={search.query}

View File

@@ -11,13 +11,44 @@ import Cookie from "../islands/Cookie.jsx";
import rawCookie from "../content/site/cookie.yaml?raw"; import rawCookie from "../content/site/cookie.yaml?raw";
const cookieCfg = yaml.parse(rawCookie); const cookieCfg = yaml.parse(rawCookie);
const { seo } = Astro.props;
// ✅ Pobierz wszystkie możliwe props
const {
seo, // Pełny obiekt SEO (stary sposób)
title, // Indywidualny title (nowy sposób)
description, // Indywidualny description (nowy sposób)
image, // Opcjonalny image
keywords, // Opcjonalne keywords
url, // Opcjonalny url
} = Astro.props;
// ✅ PRIORYTET: title/description → seo → undefined
let finalSeo;
// Jeśli mamy indywidualne pola (title lub description) - użyj ich
if (title || description) {
finalSeo = {
page: {
title,
description,
image,
keywords,
url,
},
};
}
// Jeśli nie ma indywidualnych, ale jest seo object - użyj go
else if (seo) {
finalSeo = seo;
}
// Jeśli nic nie ma - undefined (użyje global defaults z BaseHead)
else {
finalSeo = undefined;
}
--- ---
<html lang="pl" class="scroll-smooth"> <html lang="pl" class="scroll-smooth">
<head> <BaseHead seo={finalSeo} />
<BaseHead seo={seo} />
</head>
<body class="min-h-screen flex flex-col"> <body class="min-h-screen flex flex-col">
<Header /> <Header />
@@ -32,4 +63,4 @@ const { seo } = Astro.props;
<ThemeToggle client:idle /> <ThemeToggle client:idle />
</div> </div>
</body> </body>
</html> </html>

View File

@@ -4,14 +4,15 @@ import yaml from "js-yaml";
export type DocYaml = { export type DocYaml = {
title: string; title: string;
description: string;
visible?: boolean; visible?: boolean;
intro?: string; content: string;
content: string;
}; };
export type DocEntry = DocYaml & { export type DocEntry = DocYaml & {
slug: string; slug: string;
file: string; file: string;
description: string;
}; };
const DOCS_DIR = path.join(process.cwd(), "src", "content", "document"); const DOCS_DIR = path.join(process.cwd(), "src", "content", "document");
@@ -34,13 +35,14 @@ export function listDocuments(): DocEntry[] {
if (!data.title || typeof data.title !== "string") continue; if (!data.title || typeof data.title !== "string") continue;
if (!data.content || typeof data.content !== "string") continue; if (!data.content || typeof data.content !== "string") continue;
if (!data.description || typeof data.description !== "string") continue;
items.push({ items.push({
slug, slug,
file, file,
title: data.title, title: data.title,
description: data.description,
visible: data.visible ?? false, visible: data.visible ?? false,
intro: data.intro ?? "",
content: data.content, content: data.content,
}); });
} }
@@ -60,14 +62,15 @@ export function getDocumentBySlug(slug: string): DocEntry | null {
if (!data.title || typeof data.title !== "string") return null; if (!data.title || typeof data.title !== "string") return null;
if (!data.content || typeof data.content !== "string") return null; if (!data.content || typeof data.content !== "string") return null;
if (!data.description || typeof data.description !== "string") continue;
return { return {
slug, slug,
file, file,
title: data.title, title: data.title,
visible: data.visible ?? false, visible: data.visible ?? false,
intro: data.intro ?? "",
content: data.content, content: data.content,
description: data.description,
}; };
} }

View File

@@ -15,7 +15,7 @@ if (!doc || doc.visible !== true) {
const html = marked.parse(doc.content); const html = marked.parse(doc.content);
--- ---
<DefaultLayout title={doc.title}> <DefaultLayout title={doc.title} description={doc.description}>
<section class="f-section"> <section class="f-section">
<div class="f-section-grid-single"> <div class="f-section-grid-single">
<a href="/dokumenty" class="f-document-link"> <a href="/dokumenty" class="f-document-link">

View File

@@ -12,6 +12,8 @@ type YamlSection = {
}; };
type YamlData = { type YamlData = {
title?: string;
description?: string;
sections?: YamlSection[]; sections?: YamlSection[];
}; };
@@ -22,10 +24,16 @@ let items: Array<{
content: string; content: string;
}> = []; }> = [];
let pageTitle = "";
let pageDescription = "";
let err = ""; let err = "";
try { try {
const data = loadYaml<YamlData>("./src/content/internet-telewizja/telewizja-mozliwosci.yaml"); const data = loadYaml<YamlData>(
"./src/content/internet-telewizja/telewizja-mozliwosci.yaml",
);
pageTitle = data?.title || pageTitle;
pageDescription = data?.description || pageDescription;
const sections = safeArray<YamlSection>(data?.sections); const sections = safeArray<YamlSection>(data?.sections);
items = sections items = sections
@@ -42,7 +50,7 @@ try {
} }
--- ---
<DefaultLayout title="Możliwości JAMBOX"> <DefaultLayout title={pageTitle} description={pageDescription}>
<section class="f-section" id="top"> <section class="f-section" id="top">
<div class="f-section-grid-single"> <div class="f-section-grid-single">
<h1 class="f-section-title">Możliwości JAMBOX</h1> <h1 class="f-section-title">Możliwości JAMBOX</h1>
@@ -63,4 +71,4 @@ try {
) )
} }
</section> </section>
</DefaultLayout> </DefaultLayout>

View File

@@ -28,7 +28,7 @@ const seo = loadYaml("./src/content/mapa-zasiegu/seo.yaml");
class="w-full md:w-[340px] bg-[var(--f-background)] text-[var(--f-text)] class="w-full md:w-[340px] bg-[var(--f-background)] text-[var(--f-text)]
pt-6 px-6 flex flex-col gap-6 overflow-y-auto z-40" pt-6 px-6 flex flex-col gap-6 overflow-y-auto z-40"
> >
<h3 class="text-3xl">Sprawdź dostępność usług</h3> <h1 class="text-3xl">Sprawdź dostępność usług</h1>
<p class="text-sm"> <p class="text-sm">
Wybierz swoją miejscowość i ulicę oraz numer budynku, aby sprawdzić Wybierz swoją miejscowość i ulicę oraz numer budynku, aby sprawdzić
dostępność usług światłowodowych FUZ. dostępność usług światłowodowych FUZ.