diff --git a/src/assets/images/background1.png b/src/assets/images/background1.png deleted file mode 100644 index da8aba0..0000000 Binary files a/src/assets/images/background1.png and /dev/null differ diff --git a/src/assets/images/logo.png b/src/assets/images/fwt.png similarity index 100% rename from src/assets/images/logo.png rename to src/assets/images/fwt.png diff --git a/src/assets/optimized/background.avif b/src/assets/optimized/background.avif new file mode 100644 index 0000000..70acab9 Binary files /dev/null and b/src/assets/optimized/background.avif differ diff --git a/src/assets/optimized/background.webp b/src/assets/optimized/background.webp new file mode 100644 index 0000000..5ab4880 Binary files /dev/null and b/src/assets/optimized/background.webp differ diff --git a/src/templates/images/logo.avif b/src/assets/optimized/fwt.avif similarity index 100% rename from src/templates/images/logo.avif rename to src/assets/optimized/fwt.avif diff --git a/src/templates/images/logo.webp b/src/assets/optimized/fwt.webp similarity index 100% rename from src/templates/images/logo.webp rename to src/assets/optimized/fwt.webp diff --git a/src/assets/optimized/sample.avif b/src/assets/optimized/sample.avif new file mode 100644 index 0000000..78c62db Binary files /dev/null and b/src/assets/optimized/sample.avif differ diff --git a/src/assets/optimized/sample.webp b/src/assets/optimized/sample.webp new file mode 100644 index 0000000..0cb2279 Binary files /dev/null and b/src/assets/optimized/sample.webp differ diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index c2cc0e2..e964c50 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -4,21 +4,21 @@ const { title } = Astro.props const websiteName = 'Template' const websiteDescription = 'This is just a template.' -import Background from '../templates/components/Background/Background' +import Background from '../templates/Background/Background' --- - + {title} - + diff --git a/src/templates/components/Background/Background.sass b/src/templates/Background/Background.sass similarity index 100% rename from src/templates/components/Background/Background.sass rename to src/templates/Background/Background.sass diff --git a/src/templates/Background/Background.tsx b/src/templates/Background/Background.tsx new file mode 100644 index 0000000..c55c9c5 --- /dev/null +++ b/src/templates/Background/Background.tsx @@ -0,0 +1,44 @@ +import './Background.sass' +import { Show } from 'solid-js' +import sharp from 'sharp' +import fs from 'fs' + +interface Props { + image?: boolean + color?: string +} + +const webpOutputPath = 'src/assets/optimized/background.webp' +const avifOutputPath = 'src/assets/optimized/background.avif' + +const convertBackground = async (props: Props) => { + const inputPath = 'src/assets/images/background.png' + + if (!fs.existsSync(webpOutputPath) || !fs.existsSync(avifOutputPath)) { + const avifBuffer = await sharp(inputPath).avif({ quality: 60 }).resize(1920).toBuffer() + await sharp(avifBuffer).toFile(avifOutputPath) + + const webpBuffer = await sharp(inputPath).webp({ quality: 75 }).resize(1920).toBuffer() + await sharp(webpBuffer).toFile(webpOutputPath) + } +} + +export default (props: Props) => { + convertBackground(props) + + return ( + <> + + + + + An image background + + + + +
+ + + ) +} diff --git a/src/templates/components/Button/Button.sass b/src/templates/Button/Button.sass similarity index 100% rename from src/templates/components/Button/Button.sass rename to src/templates/Button/Button.sass diff --git a/src/templates/components/Button/Button.tsx b/src/templates/Button/Button.tsx similarity index 98% rename from src/templates/components/Button/Button.tsx rename to src/templates/Button/Button.tsx index 61b7e7a..156b29f 100644 --- a/src/templates/components/Button/Button.tsx +++ b/src/templates/Button/Button.tsx @@ -1,3 +1,4 @@ +import { boolean } from 'astro:schema' import './Button.sass' import { Show, Switch, Match } from 'solid-js' diff --git a/src/templates/components/Image/Image.tsx b/src/templates/Image/Image.tsx similarity index 100% rename from src/templates/components/Image/Image.tsx rename to src/templates/Image/Image.tsx diff --git a/src/templates/components/Link/Link.tsx b/src/templates/Link/Link.tsx similarity index 100% rename from src/templates/components/Link/Link.tsx rename to src/templates/Link/Link.tsx diff --git a/src/templates/components/Page/Page.sass b/src/templates/Page/Page.sass similarity index 100% rename from src/templates/components/Page/Page.sass rename to src/templates/Page/Page.sass diff --git a/src/templates/components/Page/Page.tsx b/src/templates/Page/Page.tsx similarity index 100% rename from src/templates/components/Page/Page.tsx rename to src/templates/Page/Page.tsx diff --git a/src/templates/components/Background/Background.tsx b/src/templates/components/Background/Background.tsx deleted file mode 100644 index e33e37d..0000000 --- a/src/templates/components/Background/Background.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import './Background.sass' -import { Show, createSignal } from 'solid-js' -import fs from 'fs' -import webpPath from '../../../templates/images/background.webp' -import avifPath from '../../../templates/images/background.avif' -import noBackground from '../../../templates/images/no-background.webp' - -interface Props { - image?: boolean - color?: string -} - -let [imageLoaded, setImageLoaded] = createSignal(false) - -const checkBackground = () => { - if (!fs.existsSync(avifPath.src) && !fs.existsSync(webpPath.src)) { - setImageLoaded(true) - } else { - setImageLoaded(false) - } -} - -export default (props: Props) => { - checkBackground() - - return ( - <> - - - - - - - An image background - - - - - - An alternative background if found no image background - - - - - -
- - - ) -} diff --git a/src/templates/components/Logo/Logo.tsx b/src/templates/components/Logo/Logo.tsx deleted file mode 100644 index d293b1a..0000000 --- a/src/templates/components/Logo/Logo.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import webpPath from '../../../templates/images/logo.webp' -import avifPath from '../../../templates/images/logo.avif' - -interface Props { - size?: number - alt?: string -} - -export default (props: Props) => { - return ( - <> - - - - logo - - - ) -} diff --git a/src/templates/components/Optimizer/OptimizeBackground.tsx b/src/templates/components/Optimizer/OptimizeBackground.tsx deleted file mode 100644 index 2c004f5..0000000 --- a/src/templates/components/Optimizer/OptimizeBackground.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import sharp from 'sharp' - -const convertBackground = async () => { - const inputSrc = 'src/assets/images/background.png' - const webpOutput = 'src/templates/images/background.webp' - const avifOutput = 'src/templates/images/background.avif' - - const avifBuffer = await sharp(inputSrc).avif({ quality: 60 }).resize(1920).toBuffer() - await sharp(avifBuffer).toFile(avifOutput) - - const webpBuffer = await sharp(inputSrc).webp({ quality: 75 }).resize(1920).toBuffer() - await sharp(webpBuffer).toFile(webpOutput) -} - -export default () => { - convertBackground() -} diff --git a/src/templates/components/Optimizer/OptimizeLogo.tsx b/src/templates/components/Optimizer/OptimizeLogo.tsx deleted file mode 100644 index fb39b0d..0000000 --- a/src/templates/components/Optimizer/OptimizeLogo.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import sharp from 'sharp' - -interface Props { - size?: number - alt?: string -} - -const convertLogo = async (props: Props) => { - const inputSrc = 'src/assets/images/logo.png' - const webpImage = 'src/templates/images/logo.webp' - const avifImage = 'src/templates/images/logo.avif' - - const avifBuffer = await sharp(inputSrc).avif({ quality: 60 }).resize(props.size).toBuffer() - await sharp(avifBuffer).toFile(avifImage) - - const webpBuffer = await sharp(inputSrc).webp({ quality: 75 }).resize(props.size).toBuffer() - await sharp(webpBuffer).toFile(webpImage) -} - -export default (props: Props) => { - convertLogo(props) -} diff --git a/src/templates/images/background.avif b/src/templates/images/background.avif deleted file mode 100644 index c002cfe..0000000 Binary files a/src/templates/images/background.avif and /dev/null differ diff --git a/src/templates/images/background.webp b/src/templates/images/background.webp deleted file mode 100644 index c10b40b..0000000 Binary files a/src/templates/images/background.webp and /dev/null differ diff --git a/src/templates/images/no-background.webp b/src/templates/images/no-background.webp deleted file mode 100644 index 87c7f4c..0000000 Binary files a/src/templates/images/no-background.webp and /dev/null differ