Use Prettier
This commit is contained in:
@ -2,47 +2,47 @@
|
||||
---
|
||||
|
||||
<script is:inline>
|
||||
// Set "light" theme as default
|
||||
// if (!localStorage.theme) {
|
||||
// localStorage.theme = "light";
|
||||
// }
|
||||
// Set "light" theme as default
|
||||
// if (!localStorage.theme) {
|
||||
// localStorage.theme = "light";
|
||||
// }
|
||||
|
||||
if (
|
||||
localStorage.theme === "dark" ||
|
||||
(!("theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches)
|
||||
) {
|
||||
document.documentElement.classList.add("dark");
|
||||
} else {
|
||||
document.documentElement.classList.remove("dark");
|
||||
}
|
||||
if (
|
||||
localStorage.theme === 'dark' ||
|
||||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
) {
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
|
||||
function attachEvent(selector, event, fn) {
|
||||
const matches = document.querySelectorAll(selector);
|
||||
if (matches && matches.length) {
|
||||
matches.forEach((elem) => {
|
||||
elem.addEventListener(event, () => fn(elem), false);
|
||||
});
|
||||
}
|
||||
}
|
||||
function attachEvent(selector, event, fn) {
|
||||
const matches = document.querySelectorAll(selector);
|
||||
if (matches && matches.length) {
|
||||
matches.forEach((elem) => {
|
||||
elem.addEventListener(event, () => fn(elem), false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
attachEvent("[data-aw-toggle-menu]", "click", function (elem) {
|
||||
elem.classList.toggle("expanded");
|
||||
document.body.classList.toggle("overflow-hidden");
|
||||
document.getElementById("menu")?.classList.toggle("hidden");
|
||||
});
|
||||
window.onload = function () {
|
||||
attachEvent('[data-aw-toggle-menu]', 'click', function (elem) {
|
||||
elem.classList.toggle('expanded');
|
||||
document.body.classList.toggle('overflow-hidden');
|
||||
document.getElementById('menu')?.classList.toggle('hidden');
|
||||
});
|
||||
|
||||
attachEvent("[data-aw-toggle-color-scheme]", "click", function () {
|
||||
document.documentElement.classList.toggle("dark");
|
||||
localStorage.theme = document.documentElement.classList.contains("dark") ? "dark" : "light";
|
||||
});
|
||||
};
|
||||
window.onpageshow = function () {
|
||||
const elem = document.querySelector("[data-aw-toggle-menu]");
|
||||
if (elem) {
|
||||
elem.classList.remove("expanded");
|
||||
}
|
||||
document.body.classList.remove("overflow-hidden");
|
||||
document.getElementById("menu")?.classList.add("hidden");
|
||||
};
|
||||
attachEvent('[data-aw-toggle-color-scheme]', 'click', function () {
|
||||
document.documentElement.classList.toggle('dark');
|
||||
localStorage.theme = document.documentElement.classList.contains('dark') ? 'dark' : 'light';
|
||||
});
|
||||
};
|
||||
window.onpageshow = function () {
|
||||
const elem = document.querySelector('[data-aw-toggle-menu]');
|
||||
if (elem) {
|
||||
elem.classList.remove('expanded');
|
||||
}
|
||||
document.body.classList.remove('overflow-hidden');
|
||||
document.getElementById('menu')?.classList.add('hidden');
|
||||
};
|
||||
</script>
|
||||
|
@ -1,16 +1,16 @@
|
||||
---
|
||||
const { id = "G-XXXXXXXXXX", partytown = false } = Astro.props;
|
||||
const { id = 'G-XXXXXXXXXX', partytown = false } = Astro.props;
|
||||
|
||||
const attrs = partytown ? { type: "text/partytown" } : {};
|
||||
const attrs = partytown ? { type: 'text/partytown' } : {};
|
||||
---
|
||||
|
||||
<script is:inline async src={`https://www.googletagmanager.com/gtag/js?id=${id}`} {...attrs}></script>
|
||||
|
||||
<script is:inline define:vars={{ id }} {...attrs}>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
window.dataLayer.push(arguments);
|
||||
}
|
||||
gtag("js", new Date());
|
||||
gtag("config", id);
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
window.dataLayer.push(arguments);
|
||||
}
|
||||
gtag('js', new Date());
|
||||
gtag('config', id);
|
||||
</script>
|
||||
|
@ -1,35 +1,35 @@
|
||||
---
|
||||
import { getImage } from "@astrojs/image";
|
||||
import { getRelativeUrlByFilePath } from "~/utils/directories";
|
||||
import { getImage } from '@astrojs/image';
|
||||
import { getRelativeUrlByFilePath } from '~/utils/directories';
|
||||
|
||||
import GoogleAnalytics from "~/components/core/GoogleAnalytics.astro";
|
||||
import defaultImageSrc from "~/assets/images/default.png";
|
||||
import GoogleAnalytics from '~/components/core/GoogleAnalytics.astro';
|
||||
import defaultImageSrc from '~/assets/images/default.png';
|
||||
|
||||
import { SITE } from "~/config.mjs";
|
||||
import Fonts from "../atoms/Fonts.astro";
|
||||
import ExtraMetaTags from "../atoms/ExtraMetaTags.astro";
|
||||
import { SITE } from '~/config.mjs';
|
||||
import Fonts from '../atoms/Fonts.astro';
|
||||
import ExtraMetaTags from '../atoms/ExtraMetaTags.astro';
|
||||
|
||||
const { src: defaultImage } = await getImage({
|
||||
src: defaultImageSrc,
|
||||
width: 1200,
|
||||
height: 628,
|
||||
src: defaultImageSrc,
|
||||
width: 1200,
|
||||
height: 628,
|
||||
});
|
||||
|
||||
const {
|
||||
title = SITE.name,
|
||||
description = "",
|
||||
image: _image = defaultImage,
|
||||
canonical,
|
||||
noindex = false,
|
||||
nofollow = false,
|
||||
title = SITE.name,
|
||||
description = '',
|
||||
image: _image = defaultImage,
|
||||
canonical,
|
||||
noindex = false,
|
||||
nofollow = false,
|
||||
} = Astro.props;
|
||||
|
||||
const image =
|
||||
typeof _image === "string"
|
||||
? new URL(_image, Astro.site)
|
||||
: _image && typeof _image["src"] !== "undefined"
|
||||
? new URL(getRelativeUrlByFilePath(_image.src), Astro.site)
|
||||
: null;
|
||||
typeof _image === 'string'
|
||||
? new URL(_image, Astro.site)
|
||||
: _image && typeof _image['src'] !== 'undefined'
|
||||
? new URL(getRelativeUrlByFilePath(_image.src), Astro.site)
|
||||
: null;
|
||||
---
|
||||
|
||||
<meta charset="UTF-8" />
|
||||
@ -39,7 +39,7 @@ const image =
|
||||
<meta name="description" content={description} />
|
||||
{canonical && <link rel="canonical" href={canonical} />}
|
||||
|
||||
<meta name="robots" content={`${noindex ? "noindex" : "index"}, ${nofollow ? "nofollow" : "follow"}`} />
|
||||
<meta name="robots" content={`${noindex ? 'noindex' : 'index'}, ${nofollow ? 'nofollow' : 'follow'}`} />
|
||||
|
||||
<!-- Google / Search Engine Tags -->
|
||||
<meta itemprop="name" content={title} />
|
||||
|
@ -1,39 +1,43 @@
|
||||
---
|
||||
import { getPicture } from "@astrojs/image";
|
||||
import { getPicture } from '@astrojs/image';
|
||||
|
||||
const {
|
||||
src,
|
||||
alt,
|
||||
sizes,
|
||||
widths,
|
||||
aspectRatio = 1,
|
||||
formats = ["avif", "webp"],
|
||||
loading = "lazy",
|
||||
decoding = "async",
|
||||
class: className = "",
|
||||
...attrs
|
||||
src,
|
||||
alt,
|
||||
sizes,
|
||||
widths,
|
||||
aspectRatio = 1,
|
||||
formats = ['avif', 'webp'],
|
||||
loading = 'lazy',
|
||||
decoding = 'async',
|
||||
class: className = '',
|
||||
...attrs
|
||||
} = Astro.props;
|
||||
|
||||
let picture = null;
|
||||
try {
|
||||
picture = src && await getPicture({
|
||||
src,
|
||||
widths,
|
||||
formats,
|
||||
aspectRatio,
|
||||
})
|
||||
}
|
||||
catch (e) {
|
||||
// continue regardless of error
|
||||
picture =
|
||||
src &&
|
||||
(await getPicture({
|
||||
src,
|
||||
widths,
|
||||
formats,
|
||||
aspectRatio,
|
||||
}));
|
||||
} catch (e) {
|
||||
// continue regardless of error
|
||||
}
|
||||
|
||||
const { image = {}, sources = [] } = picture || {}
|
||||
const { image = {}, sources = [] } = picture || {};
|
||||
---
|
||||
|
||||
{ (src && image?.src) &&
|
||||
<picture {...attrs}>
|
||||
{sources.map((attrs) =>
|
||||
<source {...attrs} {sizes} />)}
|
||||
<img {...image} {loading} {decoding} {alt} class={className} />
|
||||
</picture>
|
||||
}
|
||||
{
|
||||
src && image?.src && (
|
||||
<picture {...attrs}>
|
||||
{sources.map((attrs) => (
|
||||
<source {...attrs} sizes={sizes} />
|
||||
))}
|
||||
<img {...image} {loading} {decoding} {alt} class={className} />
|
||||
</picture>
|
||||
)
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
---
|
||||
import { Icon } from "astro-icon";
|
||||
import { Icon } from 'astro-icon';
|
||||
|
||||
const {
|
||||
label = "Toggle Menu",
|
||||
class:
|
||||
className = "ml-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center transition",
|
||||
iconClass = "w-6 h-6",
|
||||
iconName = "tabler:menu",
|
||||
label = 'Toggle Menu',
|
||||
class:
|
||||
className = 'ml-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center transition',
|
||||
iconClass = 'w-6 h-6',
|
||||
iconName = 'tabler:menu',
|
||||
} = Astro.props;
|
||||
---
|
||||
|
||||
<button type="button" class={className} aria-label={label} data-aw-toggle-menu>
|
||||
<Icon name={iconName} class={iconClass} optimize={false} />
|
||||
</button>
|
||||
<Icon name={iconName} class={iconClass} optimize={false} />
|
||||
</button>
|
||||
|
@ -1,15 +1,15 @@
|
||||
---
|
||||
import { Icon } from "astro-icon";
|
||||
import { Icon } from 'astro-icon';
|
||||
|
||||
const {
|
||||
label = "Toggle between Dark and Light mode",
|
||||
class:
|
||||
className = "text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center",
|
||||
iconClass = "w-6 h-6",
|
||||
iconName = "tabler:sun",
|
||||
label = 'Toggle between Dark and Light mode',
|
||||
class:
|
||||
className = 'text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center',
|
||||
iconClass = 'w-6 h-6',
|
||||
iconName = 'tabler:sun',
|
||||
} = Astro.props;
|
||||
---
|
||||
|
||||
<button type="button" class={className} aria-label={label} data-aw-toggle-color-scheme>
|
||||
<Icon name={iconName} class={iconClass} />
|
||||
<Icon name={iconName} class={iconClass} />
|
||||
</button>
|
||||
|
Reference in New Issue
Block a user