diff --git a/package.json b/package.json index c2d16cf..b05b8a5 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "angular-ru-interview-questions", "version": "1.0.0", "private": true, - "description": "Вопросы подготовлены непосредственно для того, чтобы определить уровень разработчика, насколько глубоко, поверхностно или сносно он знает Angular. Вопросы для собеседования на знание JavaScript или Web-стека хорошо освещены в других местах, поэтому ниже будет добавлен список ресурсов по этой теме:", - "homepage": "https://github.com/Angular-RU/angular-ru-interview-questions#readme", + "description": "Справочник с вопросами, ответами и практическими заданиями для подготовки разработчиков к техническим собеседованиям", + "homepage": "https://angular-ru.github.io/interview/", "bugs": { "url": "https://github.com/Angular-RU/angular-ru-interview-questions/issues" }, @@ -19,7 +19,8 @@ "predev": "npm run prebuild", "dev": "astro dev", "prebuild": "npm run build:public --workspaces --if-present", - "build": "astro build", + "build": "astro build && npm run build:search", + "build:search": "npx --yes pagefind@1.5.2 --site dist --exclude-selectors \".sidebar-navigation, .site-search\"", "preview": "astro preview", "astro": "astro", "format": "prettier \"!package-lock.json\" . --ignore-path .gitignore --write", diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 03a9565..4ee9cb0 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -4,15 +4,39 @@ import {ClientRouter} from 'astro:transitions'; import SidebarNavigation from '../components/SidebarNavigation.astro'; import '../styles/global.css'; -const {frontmatter} = Astro.props; +interface MarkdownHeading { + readonly depth: number; + readonly slug: string; + readonly text: string; +} + +interface Frontmatter { + readonly title?: string; + readonly description?: string; +} + +interface Props { + readonly title?: string; + readonly description?: string; + readonly frontmatter?: Frontmatter; + readonly headings?: readonly MarkdownHeading[]; +} + +const {title: titleFromProps, description: descriptionFromProps, frontmatter, headings = []} = Astro.props; + +const title = titleFromProps ?? frontmatter?.title ?? 'Angular RU Interview Questions'; +const description = + descriptionFromProps ?? frontmatter?.description ?? 'Вопросы и практические задания для подготовки разработчиков'; -const title = frontmatter?.title ?? 'Angular RU Interview Questions'; -const description = frontmatter?.description ?? 'Вопросы и практические задания для подготовки разработчиков'; -const headings = Astro.props.headings ?? []; const basePath = import.meta.env.BASE_URL.replace(/\/$/, ''); const currentPath = Astro.url.pathname.replace(/\/$/, ''); const homeHref = `${basePath}/`; const showHomeLink = currentPath !== basePath; + +const canonicalUrl = new URL(Astro.url.pathname, Astro.site ?? Astro.url.origin); +const pagefindPath = `${basePath}/pagefind`; +const searchBasePath = `${basePath}/`; +const searchEnabled = import.meta.env.PROD; --- @@ -27,13 +51,77 @@ const showHomeLink = currentPath !== basePath; name="viewport" content="width=device-width, initial-scale=1.0" /> + + + + + + + + { + searchEnabled && ( + + ) + }