aboutsummaryrefslogtreecommitdiff
path: root/examples/docs/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'examples/docs/src/components')
-rw-r--r--examples/docs/src/components/Footer/AvatarList.astro2
-rw-r--r--examples/docs/src/components/Footer/Footer.astro2
-rw-r--r--examples/docs/src/components/HeadSEO.astro26
-rw-r--r--examples/docs/src/components/Header/AstroLogo.astro2
-rw-r--r--examples/docs/src/components/Header/Header.astro6
-rw-r--r--examples/docs/src/components/Header/Search.tsx2
-rw-r--r--examples/docs/src/components/LeftSidebar/LeftSidebar.astro4
-rw-r--r--examples/docs/src/components/PageContent/PageContent.astro8
-rw-r--r--examples/docs/src/components/RightSidebar/MoreMenu.astro10
-rw-r--r--examples/docs/src/components/RightSidebar/RightSidebar.astro4
-rw-r--r--examples/docs/src/components/RightSidebar/TableOfContents.tsx2
11 files changed, 30 insertions, 38 deletions
diff --git a/examples/docs/src/components/Footer/AvatarList.astro b/examples/docs/src/components/Footer/AvatarList.astro
index 03b1e5bd7..8d00e0ec6 100644
--- a/examples/docs/src/components/Footer/AvatarList.astro
+++ b/examples/docs/src/components/Footer/AvatarList.astro
@@ -3,7 +3,7 @@
type Props = {
path: string;
};
-const { path } = Astro.props as Props;
+const { path } = Astro.props;
const resolvedPath = `examples/docs/${path}`;
const url = `https://api.github.com/repos/withastro/astro/commits?path=${resolvedPath}`;
const commitsURL = `https://github.com/withastro/astro/commits/main/${resolvedPath}`;
diff --git a/examples/docs/src/components/Footer/Footer.astro b/examples/docs/src/components/Footer/Footer.astro
index 1ec756b86..8eab03d82 100644
--- a/examples/docs/src/components/Footer/Footer.astro
+++ b/examples/docs/src/components/Footer/Footer.astro
@@ -3,7 +3,7 @@ import AvatarList from './AvatarList.astro';
type Props = {
path: string;
};
-const { path } = Astro.props as Props;
+const { path } = Astro.props;
---
<footer>
diff --git a/examples/docs/src/components/HeadSEO.astro b/examples/docs/src/components/HeadSEO.astro
index c40e04327..e8ac787d3 100644
--- a/examples/docs/src/components/HeadSEO.astro
+++ b/examples/docs/src/components/HeadSEO.astro
@@ -1,16 +1,14 @@
---
-import { SITE, OPEN_GRAPH, Frontmatter } from '../config';
+import type { CollectionEntry } from 'astro:content';
+import { SITE, OPEN_GRAPH } from '../consts';
-export interface Props {
- frontmatter: Frontmatter;
- canonicalUrl: URL;
-}
+type Props = { canonicalUrl: URL } & CollectionEntry<'docs'>['data'];
-const { frontmatter, canonicalUrl } = Astro.props as Props;
-const formattedContentTitle = `${frontmatter.title} 🚀 ${SITE.title}`;
-const imageSrc = frontmatter.image?.src ?? OPEN_GRAPH.image.src;
+const { ogLocale, image, title, description, canonicalUrl } = Astro.props;
+const formattedContentTitle = `${title} 🚀 ${SITE.title}`;
+const imageSrc = image?.src ?? OPEN_GRAPH.image.src;
const canonicalImageSrc = new URL(imageSrc, Astro.site);
-const imageAlt = frontmatter.image?.alt ?? OPEN_GRAPH.image.alt;
+const imageAlt = image?.alt ?? OPEN_GRAPH.image.alt;
---
<!-- Page Metadata -->
@@ -20,21 +18,17 @@ const imageAlt = frontmatter.image?.alt ?? OPEN_GRAPH.image.alt;
<meta property="og:title" content={formattedContentTitle} />
<meta property="og:type" content="article" />
<meta property="og:url" content={canonicalUrl} />
-<meta property="og:locale" content={frontmatter.ogLocale ?? SITE.defaultLanguage} />
+<meta property="og:locale" content={ogLocale ?? SITE.defaultLanguage} />
<meta property="og:image" content={canonicalImageSrc} />
<meta property="og:image:alt" content={imageAlt} />
-<meta
- name="description"
- property="og:description"
- content={frontmatter.description ?? SITE.description}
-/>
+<meta name="description" property="og:description" content={description ?? SITE.description} />
<meta property="og:site_name" content={SITE.title} />
<!-- Twitter Tags -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content={OPEN_GRAPH.twitter} />
<meta name="twitter:title" content={formattedContentTitle} />
-<meta name="twitter:description" content={frontmatter.description ?? SITE.description} />
+<meta name="twitter:description" content={description ?? SITE.description} />
<meta name="twitter:image" content={canonicalImageSrc} />
<meta name="twitter:image:alt" content={imageAlt} />
diff --git a/examples/docs/src/components/Header/AstroLogo.astro b/examples/docs/src/components/Header/AstroLogo.astro
index 6c8b5b9ce..1363b3e32 100644
--- a/examples/docs/src/components/Header/AstroLogo.astro
+++ b/examples/docs/src/components/Header/AstroLogo.astro
@@ -2,7 +2,7 @@
type Props = {
size: number;
};
-const { size } = Astro.props as Props;
+const { size } = Astro.props;
---
<svg
diff --git a/examples/docs/src/components/Header/Header.astro b/examples/docs/src/components/Header/Header.astro
index 58fe46ee9..3f578480b 100644
--- a/examples/docs/src/components/Header/Header.astro
+++ b/examples/docs/src/components/Header/Header.astro
@@ -1,6 +1,6 @@
---
import { getLanguageFromURL, KNOWN_LANGUAGE_CODES } from '../../languages';
-import * as CONFIG from '../../config';
+import { SITE } from '../../consts';
import AstroLogo from './AstroLogo.astro';
import SkipToContent from './SkipToContent.astro';
import SidebarToggle from './SidebarToggle';
@@ -11,7 +11,7 @@ type Props = {
currentPage: string;
};
-const { currentPage } = Astro.props as Props;
+const { currentPage } = Astro.props;
const lang = getLanguageFromURL(currentPage);
---
@@ -24,7 +24,7 @@ const lang = getLanguageFromURL(currentPage);
<div class="logo flex">
<a href="/">
<AstroLogo size={40} />
- <h1>{CONFIG.SITE.title ?? 'Documentation'}</h1>
+ <h1>{SITE.title ?? 'Documentation'}</h1>
</a>
</div>
<div style="flex-grow: 1;"></div>
diff --git a/examples/docs/src/components/Header/Search.tsx b/examples/docs/src/components/Header/Search.tsx
index 19ff9fa78..620941e3a 100644
--- a/examples/docs/src/components/Header/Search.tsx
+++ b/examples/docs/src/components/Header/Search.tsx
@@ -1,6 +1,6 @@
/** @jsxImportSource react */
import { useState, useCallback, useRef } from 'react';
-import { ALGOLIA } from '../../config';
+import { ALGOLIA } from '../../consts';
import '@docsearch/css';
import './Search.css';
diff --git a/examples/docs/src/components/LeftSidebar/LeftSidebar.astro b/examples/docs/src/components/LeftSidebar/LeftSidebar.astro
index 33433f5be..22fa5bbde 100644
--- a/examples/docs/src/components/LeftSidebar/LeftSidebar.astro
+++ b/examples/docs/src/components/LeftSidebar/LeftSidebar.astro
@@ -1,12 +1,12 @@
---
import { getLanguageFromURL } from '../../languages';
-import { SIDEBAR } from '../../config';
+import { SIDEBAR } from '../../consts';
type Props = {
currentPage: string;
};
-const { currentPage } = Astro.props as Props;
+const { currentPage } = Astro.props;
const currentPageMatch = currentPage.endsWith('/')
? currentPage.slice(1, -1)
: currentPage.slice(1);
diff --git a/examples/docs/src/components/PageContent/PageContent.astro b/examples/docs/src/components/PageContent/PageContent.astro
index c7c66c7fc..24422b75a 100644
--- a/examples/docs/src/components/PageContent/PageContent.astro
+++ b/examples/docs/src/components/PageContent/PageContent.astro
@@ -1,17 +1,15 @@
---
-import type { Frontmatter } from '../../config';
+import type { MarkdownHeading } from 'astro';
import MoreMenu from '../RightSidebar/MoreMenu.astro';
import TableOfContents from '../RightSidebar/TableOfContents';
-import type { MarkdownHeading } from 'astro';
type Props = {
- frontmatter: Frontmatter;
+ title: string;
headings: MarkdownHeading[];
githubEditUrl: string;
};
-const { frontmatter, headings, githubEditUrl } = Astro.props as Props;
-const title = frontmatter.title;
+const { title, headings, githubEditUrl } = Astro.props;
---
<article id="article" class="content">
diff --git a/examples/docs/src/components/RightSidebar/MoreMenu.astro b/examples/docs/src/components/RightSidebar/MoreMenu.astro
index 4adffaff4..5dbf89678 100644
--- a/examples/docs/src/components/RightSidebar/MoreMenu.astro
+++ b/examples/docs/src/components/RightSidebar/MoreMenu.astro
@@ -1,13 +1,13 @@
---
import ThemeToggleButton from './ThemeToggleButton';
-import * as CONFIG from '../../config';
+import { COMMUNITY_INVITE_URL } from '../../consts';
type Props = {
editHref: string;
};
-const { editHref } = Astro.props as Props;
-const showMoreSection = CONFIG.COMMUNITY_INVITE_URL;
+const { editHref } = Astro.props;
+const showMoreSection = Boolean(COMMUNITY_INVITE_URL);
---
{showMoreSection && <h2 class="heading">More</h2>}
@@ -39,9 +39,9 @@ const showMoreSection = CONFIG.COMMUNITY_INVITE_URL;
)
}
{
- CONFIG.COMMUNITY_INVITE_URL && (
+ COMMUNITY_INVITE_URL && (
<li class={`header-link depth-2`}>
- <a href={CONFIG.COMMUNITY_INVITE_URL} target="_blank">
+ <a href={COMMUNITY_INVITE_URL} target="_blank">
<svg
aria-hidden="true"
focusable="false"
diff --git a/examples/docs/src/components/RightSidebar/RightSidebar.astro b/examples/docs/src/components/RightSidebar/RightSidebar.astro
index d45fbd494..2a7190e50 100644
--- a/examples/docs/src/components/RightSidebar/RightSidebar.astro
+++ b/examples/docs/src/components/RightSidebar/RightSidebar.astro
@@ -1,14 +1,14 @@
---
+import type { MarkdownHeading } from 'astro';
import TableOfContents from './TableOfContents';
import MoreMenu from './MoreMenu.astro';
-import type { MarkdownHeading } from 'astro';
type Props = {
headings: MarkdownHeading[];
githubEditUrl: string;
};
-const { headings, githubEditUrl } = Astro.props as Props;
+const { headings, githubEditUrl } = Astro.props;
---
<nav class="sidebar-nav" aria-labelledby="grid-right">
diff --git a/examples/docs/src/components/RightSidebar/TableOfContents.tsx b/examples/docs/src/components/RightSidebar/TableOfContents.tsx
index 34b0ab732..962d64ec2 100644
--- a/examples/docs/src/components/RightSidebar/TableOfContents.tsx
+++ b/examples/docs/src/components/RightSidebar/TableOfContents.tsx
@@ -1,6 +1,6 @@
-import { unescape } from 'html-escaper';
import type { MarkdownHeading } from 'astro';
import type { FunctionalComponent } from 'preact';
+import { unescape } from 'html-escaper';
import { useState, useEffect, useRef } from 'preact/hooks';
type ItemOffsets = {