From 361b439d4b5f63a7ae0dc9b49a6089d5916f6a07 Mon Sep 17 00:00:00 2001 From: Samrith Shankar Date: Wed, 1 Jan 2025 21:38:57 +0530 Subject: [PATCH] docs: custom head and descriptions --- docs/astro.config.ts | 9 ++-- docs/meta.config.ts | 27 ----------- docs/package.json | 7 ++- docs/public/robots.txt | 2 + docs/src/constants.ts | 1 + docs/src/content/docs/guides/typescript.mdx | 1 - .../guides/using-with-other-libraries.mdx | 1 - .../content/docs/guides/using-with-react.mdx | 1 - .../content/docs/project/core-concepts.mdx | 1 - .../src/content/docs/project/introduction.mdx | 1 - docs/src/content/docs/project/usage.mdx | 1 - .../content/docs/reference/package-core.mdx | 1 - .../content/docs/reference/package-react.mdx | 1 - docs/src/overrides/head.astro | 45 +++++++++++++++++++ docs/src/pages/index.astro | 3 +- package.json | 3 +- 16 files changed, 61 insertions(+), 44 deletions(-) delete mode 100644 docs/meta.config.ts create mode 100644 docs/public/robots.txt create mode 100644 docs/src/constants.ts create mode 100644 docs/src/overrides/head.astro diff --git a/docs/astro.config.ts b/docs/astro.config.ts index 8b86216..d455cf8 100644 --- a/docs/astro.config.ts +++ b/docs/astro.config.ts @@ -3,12 +3,10 @@ import starlight from "@astrojs/starlight"; import react from "@astrojs/react"; import tailwind from "@astrojs/tailwind"; -import vercelStatic from "@astrojs/vercel/static"; +import vercelStatic from "@astrojs/vercel"; import { defineConfig } from "astro/config"; -import { meta } from "./meta.config"; - const SITE = "https://genshi.samrith.dev"; // https://astro.build/config @@ -24,7 +22,7 @@ export default defineConfig({ integrations: [ starlight({ title: "Genshi", - head: meta(SITE), + // head: meta(SITE), pagination: true, titleDelimiter: "/", description: @@ -55,6 +53,9 @@ export default defineConfig({ }, ], customCss: ["./src/tailwind.css", "@fontsource-variable/inter"], + components: { + Head: "./src/overrides/head.astro", + }, }), tailwind({ applyBaseStyles: false }), react(), diff --git a/docs/meta.config.ts b/docs/meta.config.ts deleted file mode 100644 index c510077..0000000 --- a/docs/meta.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { StarlightUserConfig } from "@astrojs/starlight/types"; - -export const meta: (site: string) => StarlightUserConfig["head"] = (_site) => [ - { - tag: "meta", - attrs: { - property: "og:image", - content: "/banner.png", - }, - }, - - // Twitter - { - tag: "meta", - attrs: { - name: "twitter:card", - content: "summary_large_image", - }, - }, - { - tag: "meta", - attrs: { - name: "twitter:image", - content: "/banner.png", - }, - }, -]; diff --git a/docs/package.json b/docs/package.json index 023089c..a77749c 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,7 +1,9 @@ { "name": "docs", "type": "module", - "version": "0.0.1", + "version": "0.0.0", + "license": "UNLICENSED", + "private": true, "scripts": { "dev": "astro dev", "start": "astro dev", @@ -36,5 +38,6 @@ "eslint-plugin-astro": "~1.3.1", "prettier-plugin-astro": "~0.14.1", "typescript": "~5.7.2" - } + }, + "packageManager": "yarn@4.6.0" } diff --git a/docs/public/robots.txt b/docs/public/robots.txt new file mode 100644 index 0000000..c2a49f4 --- /dev/null +++ b/docs/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Allow: / diff --git a/docs/src/constants.ts b/docs/src/constants.ts new file mode 100644 index 0000000..93727a6 --- /dev/null +++ b/docs/src/constants.ts @@ -0,0 +1 @@ +export const SITE = "https://genshi.samrith.dev"; diff --git a/docs/src/content/docs/guides/typescript.mdx b/docs/src/content/docs/guides/typescript.mdx index 3eac4c4..8af4e7b 100644 --- a/docs/src/content/docs/guides/typescript.mdx +++ b/docs/src/content/docs/guides/typescript.mdx @@ -1,6 +1,5 @@ --- title: TypeScript -description: Making your Genshi store type-safe with TypeScript prev: false sidebar: order: -2 diff --git a/docs/src/content/docs/guides/using-with-other-libraries.mdx b/docs/src/content/docs/guides/using-with-other-libraries.mdx index a23ceb8..2f4c681 100644 --- a/docs/src/content/docs/guides/using-with-other-libraries.mdx +++ b/docs/src/content/docs/guides/using-with-other-libraries.mdx @@ -1,6 +1,5 @@ --- title: Using with other libraries -description: Learn how to use Genshi with other libraries next: false sidebar: order: 100 diff --git a/docs/src/content/docs/guides/using-with-react.mdx b/docs/src/content/docs/guides/using-with-react.mdx index 75f3670..71e9c24 100644 --- a/docs/src/content/docs/guides/using-with-react.mdx +++ b/docs/src/content/docs/guides/using-with-react.mdx @@ -1,6 +1,5 @@ --- title: Using with React -description: Learn how to use Genshi with React sidebar: order: -1 --- diff --git a/docs/src/content/docs/project/core-concepts.mdx b/docs/src/content/docs/project/core-concepts.mdx index d33f625..6ca5c08 100644 --- a/docs/src/content/docs/project/core-concepts.mdx +++ b/docs/src/content/docs/project/core-concepts.mdx @@ -1,6 +1,5 @@ --- title: Core concepts -description: The core concepts of Genshi which make it unique. sidebar: order: 0 --- diff --git a/docs/src/content/docs/project/introduction.mdx b/docs/src/content/docs/project/introduction.mdx index a9cff36..de5c92d 100644 --- a/docs/src/content/docs/project/introduction.mdx +++ b/docs/src/content/docs/project/introduction.mdx @@ -1,6 +1,5 @@ --- title: Introduction -description: Manage your application state effectively with Genshi sidebar: order: -1 --- diff --git a/docs/src/content/docs/project/usage.mdx b/docs/src/content/docs/project/usage.mdx index f466be2..f42db78 100644 --- a/docs/src/content/docs/project/usage.mdx +++ b/docs/src/content/docs/project/usage.mdx @@ -1,6 +1,5 @@ --- title: Getting Started -description: Start using Genshi in your JavaScript project. next: false sidebar: order: 0 diff --git a/docs/src/content/docs/reference/package-core.mdx b/docs/src/content/docs/reference/package-core.mdx index c53ddf3..782c17e 100644 --- a/docs/src/content/docs/reference/package-core.mdx +++ b/docs/src/content/docs/reference/package-core.mdx @@ -1,6 +1,5 @@ --- title: Core -description: API reference for the core package prev: false next: false sidebar: diff --git a/docs/src/content/docs/reference/package-react.mdx b/docs/src/content/docs/reference/package-react.mdx index 600c181..11694ca 100644 --- a/docs/src/content/docs/reference/package-react.mdx +++ b/docs/src/content/docs/reference/package-react.mdx @@ -1,6 +1,5 @@ --- title: React -description: API reference for the React package prev: false next: false sidebar: diff --git a/docs/src/overrides/head.astro b/docs/src/overrides/head.astro new file mode 100644 index 0000000..f779522 --- /dev/null +++ b/docs/src/overrides/head.astro @@ -0,0 +1,45 @@ +--- +import type { Props } from "@astrojs/starlight/props"; + +import { SITE } from "../constants"; + +const { + entry: { id, data }, +} = Astro.props; + +const BASE_TITLE = "Genshi"; +const DESCRIPTION = + "Simple, composable and effective state management for JavaScript"; +const META_IMAGE = `${SITE}/banner.png`; + +let title = data.title; + +if (!id) { + title = `${BASE_TITLE} - ${DESCRIPTION}`; +} else { + title = `${title} / ${BASE_TITLE}`; +} +--- + + +{title} + + + + + + + + + + + + + + + + + + + + diff --git a/docs/src/pages/index.astro b/docs/src/pages/index.astro index c02924a..eec21b3 100644 --- a/docs/src/pages/index.astro +++ b/docs/src/pages/index.astro @@ -6,8 +6,7 @@ import { Card, CardGrid } from "@astrojs/starlight/components"; ", "license": "MIT", "homepage": "https://github.com/samrith-s/genshi#readme", + "private": true, "type": "module", "source": "src/index.ts", "module": "lib/index.js", @@ -59,5 +60,5 @@ "vite-plugin-dts": "~3.9.1", "vitest": "~1.6.0" }, - "packageManager": "yarn@4.5.3" + "packageManager": "yarn@4.6.0" }