From 802b9915258524ab4a65bd476127706a67c456d9 Mon Sep 17 00:00:00 2001 From: Sakura Akeno Isayeki Date: Fri, 28 Jun 2024 00:58:01 +0200 Subject: [PATCH 1/2] feat(package.json): Add astro-seo-meta dependency This commit adds the "astro-seo-meta" dependency to the package.json file. This new dependency will enhance SEO meta tags generation in the AstroJS application. --- nodsoft_moltenobsidian_web/package.json | 1 + nodsoft_moltenobsidian_web/pnpm-lock.yaml | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/nodsoft_moltenobsidian_web/package.json b/nodsoft_moltenobsidian_web/package.json index 3a8f810..24e6800 100644 --- a/nodsoft_moltenobsidian_web/package.json +++ b/nodsoft_moltenobsidian_web/package.json @@ -13,6 +13,7 @@ "dependencies": { "@astrojs/sitemap": "^3.1.6", "astro": "^4.11.0", + "astro-seo-meta": "^4.1.1", "bootstrap-icons": "^1.11.3", "moltenobsidian-ssg-client": "link:..\\nodsoft_moltenobsidian_ssg_client", "sass": "^1.77.6", diff --git a/nodsoft_moltenobsidian_web/pnpm-lock.yaml b/nodsoft_moltenobsidian_web/pnpm-lock.yaml index 3293f0f..a32ef39 100644 --- a/nodsoft_moltenobsidian_web/pnpm-lock.yaml +++ b/nodsoft_moltenobsidian_web/pnpm-lock.yaml @@ -11,6 +11,9 @@ dependencies: astro: specifier: ^4.11.0 version: 4.11.0(sass@1.77.6) + astro-seo-meta: + specifier: ^4.1.1 + version: 4.1.1(astro@4.11.0) bootstrap-icons: specifier: ^1.11.3 version: 1.11.3 @@ -1049,6 +1052,14 @@ packages: resolution: {integrity: sha512-I1jXZMjAgCMmxT4qxXfPXa6SthSoE8h6gkSI9BGGNv8mP8G/v0blc+qFnZu6K42vTOiuME596QaLO0TP3Lk0xg==} dev: false + /astro-seo-meta@4.1.1(astro@4.11.0): + resolution: {integrity: sha512-hZdqKLAgjRTW4LPcYMGfH5VuA4Zidv6gYmJgw0Dw7QmPExuSLnEqFHLreRzOdQibqH4JD6PHrHoIHrUb3HUs2A==} + peerDependencies: + astro: ^4.0.0 + dependencies: + astro: 4.11.0(sass@1.77.6) + dev: false + /astro@4.11.0(sass@1.77.6): resolution: {integrity: sha512-3VWxz/08sChQIX68tuE7Y769DUdjsT3Zq2/y4SkrDRlwN9IZ/aebwcRWr5a2yMSdO2vpFxtEdobq0mKnMlLErg==} engines: {node: ^18.17.1 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0'} From 216e2327f61d97d5250944e3139668547d493121 Mon Sep 17 00:00:00 2001 From: Sakura Akeno Isayeki Date: Fri, 28 Jun 2024 01:01:29 +0200 Subject: [PATCH 2/2] feat(seo): Add SEO element + refactor head outlet - Added a new SEO component to improve search engine optimization. - Refactored the head outlet in BaseHead and Layout components to use slots for better code organization and reusability. --- .../src/components/BaseHead.astro | 35 ++----------------- .../src/layouts/Layout.astro | 5 +-- .../src/pages/404.astro | 17 +++++++++ .../src/pages/[...path].astro | 23 ++++++++++-- 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/nodsoft_moltenobsidian_web/src/components/BaseHead.astro b/nodsoft_moltenobsidian_web/src/components/BaseHead.astro index 5851db2..b7c25a7 100644 --- a/nodsoft_moltenobsidian_web/src/components/BaseHead.astro +++ b/nodsoft_moltenobsidian_web/src/components/BaseHead.astro @@ -1,15 +1,5 @@ --- import { ViewTransitions } from 'astro:transitions'; - - -// const canonicalURL = new URL(Astro.url.pathname, Astro.site); - -const defaultProps = { - title: "MoltenObsidian", - description: ".NET 6+ Library for Obsidian-flavoured Markdown parsing for Blazor with Vault mapping support." -} - -const { title, description } = defaultProps; const base = import.meta.env.BASE_URL ?? "/"; --- @@ -26,7 +16,6 @@ const base = import.meta.env.BASE_URL ?? "/"; - @@ -47,25 +36,5 @@ const base = import.meta.env.BASE_URL ?? "/"; " /> - - - - -{title} - - - - - - - - - - - - - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/nodsoft_moltenobsidian_web/src/layouts/Layout.astro b/nodsoft_moltenobsidian_web/src/layouts/Layout.astro index f2c1b4e..a158fda 100644 --- a/nodsoft_moltenobsidian_web/src/layouts/Layout.astro +++ b/nodsoft_moltenobsidian_web/src/layouts/Layout.astro @@ -5,7 +5,6 @@ import Sidebar from "../components/Sidebar.astro"; import { SITE_TITLE } from "../consts"; import { ViewTransitions } from "astro:transitions"; - interface Props { title: string; description: string; @@ -20,7 +19,9 @@ const baseHeadTitle = title ? `${title} - ${SITE_TITLE}` : SITE_TITLE; - + + + diff --git a/nodsoft_moltenobsidian_web/src/pages/404.astro b/nodsoft_moltenobsidian_web/src/pages/404.astro index fa3cd02..1d72e4f 100644 --- a/nodsoft_moltenobsidian_web/src/pages/404.astro +++ b/nodsoft_moltenobsidian_web/src/pages/404.astro @@ -2,11 +2,28 @@ import { Image } from 'astro:assets'; import logo from '../../public/android-chrome-512x512.png' import Layout from "../layouts/Layout.astro"; +import { Seo } from "astro-seo-meta"; const path = Astro.url --- + +

404

diff --git a/nodsoft_moltenobsidian_web/src/pages/[...path].astro b/nodsoft_moltenobsidian_web/src/pages/[...path].astro index 8a94956..a5bce37 100644 --- a/nodsoft_moltenobsidian_web/src/pages/[...path].astro +++ b/nodsoft_moltenobsidian_web/src/pages/[...path].astro @@ -2,10 +2,10 @@ import Layout from '../layouts/Layout.astro'; import { cast, toRelativeVaultPath } from '../vault-utils'; import { VaultManifestClient } from 'moltenobsidian-ssg-client/manifest-client'; -import { VaultManifest, VaultFile, VaultFileMetadata } from 'moltenobsidian-ssg-client/vault-manifest'; +import type { VaultManifest, VaultFile, VaultFileMetadata } from 'moltenobsidian-ssg-client/vault-manifest'; import manifest from '../../public/vault/moltenobsidian.manifest.json'; import fs from 'node:fs/promises'; -import * as console from "console"; +import { Seo } from "astro-seo-meta"; export const manifestClient = VaultManifestClient.fromManifest(manifest as VaultManifest); @@ -39,7 +39,24 @@ const { path } = Astro.params; const { content, cssclasses } = Astro.props; --- - + + +