build(astro): migrate site to Astro 6
This commit is contained in:
10 files changed
+1537
-1073
No files matched your search
@@ -1,5 +1,12 @@
|
||||
---
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import LikeViewCounter from './LikeViewCounter.astro';
|
||||
|
||||
interface Props {
|
||||
post: CollectionEntry<'blog'>;
|
||||
prefix?: string;
|
||||
}
|
||||
|
||||
const { post, prefix = '' } = Astro.props;
|
||||
const href = `${prefix}/library/${post.data.slug}`.replace('//', '/');
|
||||
const readMore = { en: 'Read More', es: 'Leer Más', ar: 'اقرأ المزيد' }[post.data.lang] || 'Read More';
|
||||
|
||||
@@ -36,7 +36,7 @@ const encodedText = encode(linkValue);
|
||||
const spanId = id ?? `${contactType}-obfuscation-${Math.random().toString(36).slice(2, 10)}`;
|
||||
---
|
||||
|
||||
<span id={spanId} class={className}>{fallbackText}</span><script type="text/javascript" define:vars={{ encodedTarget, encodedText, protocol, spanId }}>
|
||||
<span id={spanId} class={className}>{fallbackText}</span><script type="text/javascript" is:inline define:vars={{ encodedTarget, encodedText, protocol, spanId }}>
|
||||
(() => {
|
||||
const contactSpan = document.getElementById(spanId);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ const schema = {
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
<script type="application/ld+json" set:html={JSON.stringify(schema)} />
|
||||
<script type="application/ld+json" is:inline set:html={JSON.stringify(schema)} />
|
||||
|
||||
<style>
|
||||
.blog-faq {
|
||||
|
||||
@@ -66,7 +66,7 @@ import Button from '../Button.astro';
|
||||
}
|
||||
|
||||
const nodes = [...source.childNodes];
|
||||
const firstQuestionIndex = nodes.findIndex((node) => node.nodeType === Node.ELEMENT_NODE && node.tagName === 'H3');
|
||||
const firstQuestionIndex = nodes.findIndex((node) => node instanceof HTMLElement && node.tagName === 'H3');
|
||||
|
||||
if (firstQuestionIndex === -1) {
|
||||
return;
|
||||
@@ -102,8 +102,12 @@ import Button from '../Button.astro';
|
||||
answerInner.className = 'faq-answer__inner';
|
||||
|
||||
index += 1;
|
||||
while (index < nodes.length && !(nodes[index] instanceof HTMLElement && nodes[index].tagName === 'H3')) {
|
||||
while (index < nodes.length) {
|
||||
const answerNode = nodes[index];
|
||||
if (answerNode instanceof HTMLElement && answerNode.tagName === 'H3') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (answerNode.nodeType === Node.TEXT_NODE) {
|
||||
const text = answerNode.textContent?.trim();
|
||||
if (text) {
|
||||
@@ -128,21 +132,23 @@ import Button from '../Button.astro';
|
||||
nodes[i].remove();
|
||||
}
|
||||
|
||||
const faqItems = [...list.querySelectorAll('details.faq')];
|
||||
const faqItems = [...list.querySelectorAll<HTMLDetailsElement>('details.faq')];
|
||||
|
||||
const closeTimers = new WeakMap();
|
||||
const closeHandlers = new WeakMap();
|
||||
const closeTimers = new WeakMap<HTMLDetailsElement, number>();
|
||||
const closeHandlers = new WeakMap<HTMLDetailsElement, (event: TransitionEvent) => void>();
|
||||
|
||||
const getAnswer = (item) => item.querySelector('.interactive-faq-with-seo-schema-integration__list__answer');
|
||||
const getAnswerInner = (item) => item.querySelector('.faq-answer__inner');
|
||||
const getAnswer = (item: HTMLDetailsElement) =>
|
||||
item.querySelector<HTMLDivElement>('.interactive-faq-with-seo-schema-integration__list__answer');
|
||||
const getAnswerInner = (item: HTMLDetailsElement) =>
|
||||
item.querySelector<HTMLDivElement>('.faq-answer__inner');
|
||||
|
||||
const setClosedStyles = (answer) => {
|
||||
const setClosedStyles = (answer: HTMLDivElement) => {
|
||||
answer.style.height = '0px';
|
||||
answer.style.opacity = '0';
|
||||
answer.style.transform = 'translateY(-.35rem)';
|
||||
};
|
||||
|
||||
const setOpenStyles = (answer) => {
|
||||
const setOpenStyles = (answer: HTMLDivElement) => {
|
||||
answer.style.opacity = '1';
|
||||
answer.style.transform = 'translateY(0)';
|
||||
};
|
||||
@@ -164,7 +170,7 @@ import Button from '../Button.astro';
|
||||
}
|
||||
});
|
||||
|
||||
const closeItem = (item) => {
|
||||
const closeItem = (item: HTMLDetailsElement) => {
|
||||
if (!item.open || item.dataset.state === 'closing') {
|
||||
return;
|
||||
}
|
||||
@@ -183,7 +189,7 @@ import Button from '../Button.astro';
|
||||
answer.offsetHeight; // force reflow
|
||||
setClosedStyles(answer);
|
||||
|
||||
const onTransitionEnd = (event) => {
|
||||
const onTransitionEnd = (event: TransitionEvent) => {
|
||||
if (event.target !== answer || event.propertyName !== 'height') {
|
||||
return;
|
||||
}
|
||||
@@ -217,7 +223,7 @@ import Button from '../Button.astro';
|
||||
closeTimers.set(item, timer);
|
||||
};
|
||||
|
||||
const openItem = (item) => {
|
||||
const openItem = (item: HTMLDetailsElement) => {
|
||||
if (item.open && item.dataset.state !== 'closing') {
|
||||
return;
|
||||
}
|
||||
@@ -248,7 +254,7 @@ import Button from '../Button.astro';
|
||||
setOpenStyles(answer);
|
||||
});
|
||||
|
||||
const onTransitionEnd = (event) => {
|
||||
const onTransitionEnd = (event: TransitionEvent) => {
|
||||
if (event.target !== answer || event.propertyName !== 'height') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { defineCollection, z } from 'astro:content';
|
||||
import { defineCollection } from 'astro:content';
|
||||
import { glob } from 'astro/loaders';
|
||||
import { z } from 'astro/zod';
|
||||
import { homePageSchema, homeSectionsSchema } from './types/home-sections';
|
||||
|
||||
const language = z.enum(['en', 'ar', 'es']);
|
||||
@@ -7,7 +8,7 @@ const shared = {
|
||||
title: z.string(),
|
||||
description: z.string().default(''),
|
||||
slug: z.string(),
|
||||
canonical: z.string().url().optional(),
|
||||
canonical: z.url().optional(),
|
||||
featuredImage: z.string().optional(),
|
||||
alt: z.string().optional(),
|
||||
lang: language,
|
||||
|
||||
@@ -32,7 +32,7 @@ const organizationSchema = {
|
||||
<link rel="icon" href="/assets/images/favicon.svg" />
|
||||
<Seo title={title} description={description} canonical={canonical} image={image} lang={lang} type={type} />
|
||||
<slot name="head" />
|
||||
<script type="application/ld+json" set:html={JSON.stringify(organizationSchema)} />
|
||||
<script type="application/ld+json" is:inline set:html={JSON.stringify(organizationSchema)} />
|
||||
</head>
|
||||
<body>
|
||||
<a class="skip-link" href="#main">Skip to content</a>
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
---
|
||||
import BaseLayout from './BaseLayout.astro';
|
||||
import PageHero from '../components/PageHero.astro';
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
description: string;
|
||||
intro?: string[];
|
||||
lang?: 'en' | 'ar' | 'es';
|
||||
}
|
||||
|
||||
const { title, description, intro = [], lang = 'en' } = Astro.props;
|
||||
const languagePrefix = lang === 'en' ? '' : `/${lang}`;
|
||||
const canonical = `https://www.azinstitute4autism.com${languagePrefix}/library`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { z } from 'astro:content';
|
||||
import { z } from 'astro/zod';
|
||||
|
||||
const ctaSchema = z.object({
|
||||
label: z.string(),
|
||||
|
||||
Reference in new issue
Block a user