generated from avior/template-web-astro
initial recommit
This commit is contained in:
@@ -1,37 +1,15 @@
|
||||
---
|
||||
import { objectOmit } from '@dzeio/object-util'
|
||||
|
||||
export interface Props extends astroHTML.JSX.AnchorHTMLAttributes {
|
||||
outline?: boolean
|
||||
ghost?: boolean
|
||||
}
|
||||
|
||||
const classes = [
|
||||
"button",
|
||||
{outline: Astro.props.outline},
|
||||
{ghost: Astro.props.ghost},
|
||||
Astro.props.class
|
||||
]
|
||||
import Windows from './Button/Windows.astro'
|
||||
import Default from './Button/Default.astro'
|
||||
import Linux from './Button/Linux.astro'
|
||||
import Platform from './Platform.astro'
|
||||
import type ButtonProps from './Button/Props'
|
||||
|
||||
export interface Props extends ButtonProps {}
|
||||
---
|
||||
{'href' in Astro.props && (
|
||||
<a class:list={classes} {...objectOmit(Astro.props, 'type') as any}>
|
||||
<slot />
|
||||
</a>
|
||||
) || (
|
||||
<button class:list={classes} {...objectOmit(Astro.props, 'type') as any}>
|
||||
<slot />
|
||||
</button>
|
||||
)}
|
||||
|
||||
<style>
|
||||
.button {
|
||||
@apply outline-none inline-flex px-4 py-2 rounded-lg bg-amber-500 hover:bg-amber-600 active:bg-amber-700 text-white font-medium transition-colors
|
||||
}
|
||||
.button.outline {
|
||||
@apply bg-transparent border-2 text-amber-500 border-gray-200 hover:bg-gray-100 active:bg-gray-200 active:border-gray-300
|
||||
}
|
||||
.button.ghost {
|
||||
@apply text-black bg-transparent hover:bg-gray-200 active:bg-gray-300
|
||||
}
|
||||
</style>
|
||||
<Platform>
|
||||
<Linux slot="linux"><slot /></Linux>
|
||||
<Windows slot="windows"><slot /></Windows>
|
||||
<Default><slot /></Default>
|
||||
</Platform>
|
||||
|
35
src/components/global/Button/Default.astro
Normal file
35
src/components/global/Button/Default.astro
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
import { objectOmit } from '@dzeio/object-util'
|
||||
import type ButtonProps from './Props'
|
||||
|
||||
export interface Props extends ButtonProps {}
|
||||
|
||||
const classes = [
|
||||
"button",
|
||||
{outline: Astro.props.outline},
|
||||
{ghost: Astro.props.ghost},
|
||||
Astro.props.class
|
||||
]
|
||||
|
||||
---
|
||||
{'href' in Astro.props && (
|
||||
<a class:list={classes} {...objectOmit(Astro.props, 'type') as any}>
|
||||
<slot />
|
||||
</a>
|
||||
) || (
|
||||
<button class:list={classes} {...objectOmit(Astro.props, 'type') as any}>
|
||||
<slot />
|
||||
</button>
|
||||
)}
|
||||
|
||||
<style>
|
||||
.button {
|
||||
@apply outline-none inline-flex px-4 py-2 rounded-lg bg-amber-500 hover:bg-amber-600 active:bg-amber-700 text-white font-medium transition-colors
|
||||
}
|
||||
.button.outline {
|
||||
@apply bg-transparent border-2 text-amber-500 border-gray-200 hover:bg-gray-100 active:bg-gray-200 active:border-gray-300
|
||||
}
|
||||
.button.ghost {
|
||||
@apply text-black bg-transparent hover:bg-gray-200 active:bg-gray-300
|
||||
}
|
||||
</style>
|
29
src/components/global/Button/Linux.astro
Normal file
29
src/components/global/Button/Linux.astro
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
import { objectOmit } from '@dzeio/object-util'
|
||||
import type ButtonProps from './Props'
|
||||
|
||||
export interface Props extends ButtonProps {}
|
||||
|
||||
const classes = [
|
||||
"button",
|
||||
{outline: Astro.props.outline},
|
||||
{ghost: Astro.props.ghost},
|
||||
Astro.props.class
|
||||
]
|
||||
|
||||
---
|
||||
{'href' in Astro.props && (
|
||||
<a class:list={classes} {...objectOmit(Astro.props, 'type') as any}>
|
||||
<slot />
|
||||
</a>
|
||||
) || (
|
||||
<button class:list={classes} {...objectOmit(Astro.props, 'type') as any}>
|
||||
<slot />
|
||||
</button>
|
||||
)}
|
||||
|
||||
<style>
|
||||
.button {
|
||||
@apply inline-flex px-4 py-2 rounded-lg bg-gtk-neutral-200 hover:bg-gray-300 active:bg-gray-400 focus:outline-2 focus:outline outline-gtk-blue-300 text-black font-medium transition-all
|
||||
}
|
||||
</style>
|
4
src/components/global/Button/Props.d.ts
vendored
Normal file
4
src/components/global/Button/Props.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export default interface Props extends astroHTML.JSX.AnchorHTMLAttributes {
|
||||
outline?: boolean
|
||||
ghost?: boolean
|
||||
}
|
35
src/components/global/Button/Windows.astro
Normal file
35
src/components/global/Button/Windows.astro
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
import { objectOmit } from '@dzeio/object-util'
|
||||
import type ButtonProps from './Props'
|
||||
|
||||
export interface Props extends ButtonProps {}
|
||||
|
||||
const classes = [
|
||||
"button",
|
||||
{outline: Astro.props.outline},
|
||||
{ghost: Astro.props.ghost},
|
||||
Astro.props.class
|
||||
]
|
||||
|
||||
---
|
||||
{'href' in Astro.props && (
|
||||
<a class:list={classes} {...objectOmit(Astro.props, 'type') as any}>
|
||||
<slot />
|
||||
</a>
|
||||
) || (
|
||||
<button class:list={classes} {...objectOmit(Astro.props, 'type') as any}>
|
||||
<slot />
|
||||
</button>
|
||||
)}
|
||||
|
||||
<style>
|
||||
.button {
|
||||
@apply outline-none inline-flex px-4 py-2 rounded-lg bg-amber-500 hover:bg-amber-600 active:bg-amber-700 text-white font-medium transition-colors
|
||||
}
|
||||
.button.outline {
|
||||
@apply bg-transparent border-2 text-amber-500 border-gray-200 hover:bg-gray-100 active:bg-gray-200 active:border-gray-300
|
||||
}
|
||||
.button.ghost {
|
||||
@apply text-black bg-transparent hover:bg-gray-200 active:bg-gray-300
|
||||
}
|
||||
</style>
|
30
src/components/global/Platform.astro
Normal file
30
src/components/global/Platform.astro
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
type Platform = 'linux' | 'windows' | 'default'
|
||||
|
||||
const current = import.meta.env.TAURI_PLATFORM
|
||||
|
||||
let platform: Platform = 'default'
|
||||
|
||||
switch (current) {
|
||||
case 'linux':
|
||||
platform = 'linux'
|
||||
break;
|
||||
case 'windows':
|
||||
platform = 'windows'
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
---
|
||||
|
||||
{platform === 'linux' && (
|
||||
<slot name="linux"><slot /></slot>
|
||||
)}
|
||||
|
||||
{platform === 'windows' && (
|
||||
<slot name="windows"><slot /></slot>
|
||||
)}
|
||||
|
||||
{platform === 'default' && (
|
||||
<slot />
|
||||
)}
|
@@ -1,5 +1,7 @@
|
||||
---
|
||||
import { tauri } from '@tauri-apps/api'
|
||||
import Head, { type Props as HeadProps } from './Head.astro'
|
||||
import { getCurrentPlatform } from 'libs/TauriUtils'
|
||||
|
||||
export interface Props extends HeadProps {
|
||||
class?: string
|
||||
@@ -7,7 +9,7 @@ export interface Props extends HeadProps {
|
||||
---
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en" class={getCurrentPlatform()}>
|
||||
<head>
|
||||
<Head {...Astro.props} />
|
||||
<slot name="head" />
|
||||
|
@@ -57,10 +57,6 @@ const canonical = typeof Astro.props.canonical === 'string' ? Astro.props.canoni
|
||||
<!-- Viewport -->
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
|
||||
|
||||
<!-- Analytics -->
|
||||
<script defer data-domain="avior.me" src="/js/script.js"></script>
|
||||
|
||||
<!-- Favicon -->
|
||||
<Favicon svg={IconSVG} png={IconPNG} icoPath="/favicon.ico" />
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import Footer from 'components/layouts/Footer.astro'
|
||||
import Base, { type Props as BaseProps } from './Base.astro'
|
||||
import Header from 'components/layouts/Header.astro'
|
||||
import { Mail, Phone } from 'lucide-astro'
|
||||
import { Github, Linkedin } from 'simple-icons-astro'
|
||||
import { Github } from 'simple-icons-astro'
|
||||
|
||||
export interface Props extends BaseProps {
|
||||
/**
|
||||
@@ -22,7 +22,6 @@ export interface Props extends BaseProps {
|
||||
<Footer links={[
|
||||
{href: 'https://www.avior.me', display: 'About'}
|
||||
]} socials={[
|
||||
{href: 'https://linkedin.com', icon: Linkedin},
|
||||
{href: 'mailto:contact@example.com', target: '', icon: Mail},
|
||||
{href: 'tel:+33601020304', target: '', icon: Phone},
|
||||
{href: 'https://github.com/dzeiocom', icon: Github},
|
||||
|
18
src/libs/TauriUtils.ts
Normal file
18
src/libs/TauriUtils.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export function getPlatformStyle() {
|
||||
|
||||
}
|
||||
type Platform = 'linux' | 'windows' | 'default'
|
||||
|
||||
export function getCurrentPlatform(): Platform {
|
||||
const current = import.meta.env.TAURI_ENV_PLATFORM
|
||||
console.log(import.meta.env)
|
||||
|
||||
switch (current) {
|
||||
case 'linux':
|
||||
return 'linux'
|
||||
case 'windows':
|
||||
return 'windows'
|
||||
default:
|
||||
return 'default'
|
||||
}
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
# Middlewares
|
||||
|
||||
This folder contains middlewares for the SSR pages/endpoints
|
||||
|
||||
They are run for every paths independent of the middleware and in the specified order of the `index.ts`
|
||||
|
||||
## locals
|
||||
|
||||
You can pass variables to other middlewares and endpoints by adding a variable in `locals` and in `App.Locals` in `env.d.ts`
|
@@ -1,5 +0,0 @@
|
||||
import { sequence } from "astro/middleware"
|
||||
|
||||
import logger from './logger'
|
||||
|
||||
export const onRequest = sequence(logger)
|
@@ -1,53 +0,0 @@
|
||||
import { defineMiddleware } from "astro/middleware"
|
||||
import ResponseBuilder from 'libs/ResponseBuilder'
|
||||
|
||||
/**
|
||||
* Simple Middleware that handle the logging of requests and handling processing errors
|
||||
*/
|
||||
export default defineMiddleware(async ({ request, url }, next) => {
|
||||
const now = new Date()
|
||||
// Date of request User-Agent 32 first chars request Method
|
||||
let prefix = `\x1b[2m${now.toISOString()}\x1b[22m ${request.headers.get('user-agent')?.slice(0, 32).padEnd(32)} ${request.method.padEnd(7)}`
|
||||
|
||||
const fullURL = url.toString()
|
||||
const path = fullURL.slice(fullURL.indexOf(url.pathname, fullURL.indexOf(url.host)))
|
||||
|
||||
if (!import.meta.env.PROD) {
|
||||
// time of request
|
||||
prefix = `\x1b[2m${new Date().toLocaleTimeString('fr')}\x1b[22m`
|
||||
}
|
||||
|
||||
// HTTP Status Code Time to run request path of request
|
||||
console.log(`${prefix} ${''.padStart(5, ' ')} ${''.padStart(7, ' ')} ${path}`)
|
||||
|
||||
// Handle if the request die
|
||||
try {
|
||||
const res = await next()
|
||||
|
||||
if (import.meta.env.PROD) {
|
||||
// HTTP Status time to execute path of request
|
||||
console.log(`${prefix} \x1b[34m[${res.status}]\x1b[0m \x1b[2m${(new Date().getTime() - now.getTime()).toFixed(0).padStart(5, ' ')}ms\x1b[22m ${path}`)
|
||||
}
|
||||
|
||||
return res
|
||||
} catch (e) {
|
||||
if (import.meta.env.PROD) {
|
||||
// time to execute path of request
|
||||
console.log(`${prefix} \x1b[34m[500]\x1b[0m \x1b[2m${(new Date().getTime() - now.getTime()).toFixed(0).padStart(5, ' ')}ms\x1b[22m ${path}`)
|
||||
}
|
||||
|
||||
// add a full line dash to not miss it
|
||||
const columns = (process?.stdout?.columns ?? 32) - 7
|
||||
const dashes = ''.padEnd(columns / 2, '-')
|
||||
|
||||
// colorize the lines to make sur to not miss it
|
||||
console.error(`\x1b[91m${dashes} ERROR ${dashes}\x1b[0m`)
|
||||
console.error(e)
|
||||
console.error(`\x1b[91m${dashes} ERROR ${dashes}\x1b[0m`)
|
||||
|
||||
return new ResponseBuilder()
|
||||
.status(500)
|
||||
.body('An error occured while processing your request')
|
||||
.build()
|
||||
}
|
||||
})
|
@@ -1,23 +0,0 @@
|
||||
import type { APIRoute } from 'astro'
|
||||
import ResponseBuilder from '../../libs/ResponseBuilder'
|
||||
|
||||
/**
|
||||
* Plausible proxy
|
||||
*/
|
||||
export const POST: APIRoute = async ({ request, clientAddress }) => {
|
||||
// const body = await request.json()
|
||||
// console.log(body, clientAddress)
|
||||
const res = await fetch('https://plausible.io/api/event', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'User-Agent': request.headers.get('User-Agent') as string,
|
||||
'X-Forwarded-For': clientAddress,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: await request.text()
|
||||
})
|
||||
return new ResponseBuilder()
|
||||
.status(res.status)
|
||||
.body(await res.text())
|
||||
.build()
|
||||
}
|
@@ -1,10 +1,11 @@
|
||||
---
|
||||
import Button from 'components/global/Button.astro'
|
||||
import MainLayout from 'layouts/MainLayout.astro'
|
||||
---
|
||||
|
||||
<MainLayout title="Dzeio - Website Template">
|
||||
<main class="container flex flex-col justify-center items-center h-screen gap-6">
|
||||
<h1 class="text-8xl text-center">Dzeio Astro Template</h1>
|
||||
<h2 class="text-2xl text-center">Start editing src/pages/index.astro to see your changes!</h2>
|
||||
<Button>Pouet</Button>
|
||||
</main>
|
||||
</MainLayout>
|
||||
|
@@ -1,13 +0,0 @@
|
||||
import type { APIRoute } from 'astro'
|
||||
import ResponseBuilder from '../../libs/ResponseBuilder'
|
||||
|
||||
/**
|
||||
* Plausible proxy
|
||||
*/
|
||||
export const GET: APIRoute = async () => {
|
||||
const res = await fetch('https://plausible.io/js/script.outbound-links.tagged-events.js')
|
||||
return new ResponseBuilder()
|
||||
.status(200)
|
||||
.body(await res.text())
|
||||
.build()
|
||||
}
|
Reference in New Issue
Block a user