Skip to content

Commit

Permalink
Merge pull request #389 from jamerrq/pwa-support
Browse files Browse the repository at this point in the history
PWA Support
  • Loading branch information
midudev authored Mar 11, 2024
2 parents 9400cb4 + 79fdd33 commit af4135e
Show file tree
Hide file tree
Showing 27 changed files with 187 additions and 3 deletions.
24 changes: 23 additions & 1 deletion astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,44 @@ import tailwind from "@astrojs/tailwind"
import vercel from "@astrojs/vercel/serverless"
import { defineConfig } from "astro/config"

import sitemap from "@astrojs/sitemap"
import { VitePWA } from "vite-plugin-pwa"

// Helper imports
import { manifest, seoConfig } from "./src/utils/seoConfig"

// https://astro.build/config
export default defineConfig({
integrations: [tailwind()],
integrations: [tailwind(), sitemap()],
adapter: vercel({
webAnalytics: { enabled: true },
}),
build: {
inlineStylesheets: "always",
},
output: "hybrid",
site: seoConfig.baseURL,
vite: {
build: {
cssMinify: "lightningcss",
},
ssr: {
noExternal: ["path-to-regexp"],
},
plugins: [
VitePWA({
registerType: "autoUpdate",
manifest,
workbox: {
globDirectory: "dist",
globPatterns: [
"**/*.{js,css,svg,png,jpg,jpeg,gif,webp,woff,woff2,ttf,eot,ico}"
],
// Don't fallback on document based (e.g. `/some-page`) requests
// This removes an errant console.log message from showing up.
navigateFallback: null
}
})
]
},
})
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
"devDependencies": {
"@antfu/eslint-config": "0.43.1",
"@astrojs/check": "0.5.6",
"@astrojs/sitemap": "^3.1.1",
"@astrojs/tailwind": "5.1.0",
"@astrojs/vercel": "7.3.5",
"@midudev/tailwind-animations": "0.0.7",
"astro-seo": "^0.8.3",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-astro": "0.31.4",
Expand All @@ -38,6 +40,7 @@
"prettier-plugin-astro": "0.13.0",
"prettier-plugin-tailwindcss": "0.5.12",
"tailwindcss": "3.4.1",
"typescript": "5.3.3"
"typescript": "5.3.3",
"vite-plugin-pwa": "^0.19.2"
}
}
12 changes: 12 additions & 0 deletions public/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/favicon-70x70.png"/>
<square150x150logo src="/favicon-150x150.png"/>
<square310x310logo src="/favicon-310x310.png"/>
<TileColor>#ffffff</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added public/img/icons/favicon-114x114.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-310x310.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-384x384.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-57x57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-70x70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/favicon.ico
Binary file not shown.
60 changes: 60 additions & 0 deletions public/img/icons/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "La Velada",
"description": "Web Oficial de La Velada del Año IV, evento de boxeo entre streamers y creadores de contenido, organizado por Ibai Llanos.",
"short_name": "La Velada",
"icons": [
{
"src": "/favicon-72x72.png",
"type": "image/png",
"sizes": "72x72",
"purpose": "any maskable"
},
{
"src": "/favicon-96x96.png",
"type": "image/png",
"sizes": "96x96",
"purpose": "any maskable"
},
{
"src": "/favicon-128x128.png",
"type": "image/png",
"sizes": "128x128",
"purpose": "any maskable"
},
{
"src": "/favicon-144x144.png",
"type": "image/png",
"sizes": "144x144",
"purpose": "any maskable"
},
{
"src": "/favicon-152x152.png",
"type": "image/png",
"sizes": "152x152",
"purpose": "any maskable"
},
{
"src": "/favicon-192x192.png",
"type": "image/png",
"sizes": "192x192",
"purpose": "any maskable"
},
{
"src": "/favicon-384x384.png",
"type": "image/png",
"sizes": "384x384",
"purpose": "any maskable"
},
{
"src": "/favicon-512x512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "any maskable"
}
],
"scope": "/",
"start_url": "/?source=pwa",
"display": "standalone",
"theme_color": "#d5ff00",
"background_color": "#d5ff00"
}
34 changes: 34 additions & 0 deletions src/components/SEO.astro
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,38 @@ const { title, description, preloadImgLCP } = Astro.props
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow" />

<!-- PWA Support -->

<!-- Favicons. -->
<!-- 16 -->
<link rel="icon" type="image/png" sizes="16x16" href="/img/icons/favicon-16x16.png" />
<!-- 20 -->
<link rel="icon" type="image/png" sizes="20x20" href="/img/icons/favicon-20x20.png" />
<!-- 24 -->
<link rel="icon" type="image/png" sizes="24x24" href="/img/icons/favicon-24x24.png" />
<!-- 48 -->
<link rel="icon" type="image/png" sizes="48x48" href="/img/icons/favicon-48x48.png" />
<!-- 64 -->
<link rel="icon" type="image/png" sizes="64x64" href="/img/icons/favicon-64x64.png" />
<!-- 128 -->
<link rel="icon" type="image/png" sizes="128x128" href="/img/icons/favicon-128x128.png" />
<!-- 144 -->
<link rel="icon" type="image/png" sizes="144x144" href="/img/icons/favicon-144x144.png" />
<!-- 256 -->
<link rel="icon" type="image/png" sizes="256x256" href="/img/icons/favicon-256x256.png" />
<!-- 512 -->
<link rel="icon" type="image/png" sizes="512x512" href="/img/icons/favicon-512x512.png" />
<link rel="shortcut icon" type="image/x-icon" href="/img/icons/favicon.ico" />

<!-- Sitemap -->
<meta name="msapplication-config" content="/browserconfig.xml" />

<!-- Worker Registration -->
{
!import.meta.env.DEV && (
<script is:inline src="/registerSW.js"></script>
<link rel="manifest" href="/manifest.webmanifest" />
)
}

<RichResults />
2 changes: 1 addition & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { title, description, preloadImgLCP } = Astro.props
<!doctype html>
<html lang="es">
<head>
<SEO title={title} description={description} preloadImgLCP={preloadImgLCP} />
<SEO title={title} description={description} preloadImgLCP={preloadImgLCP!} />
</head>

<body
Expand Down
53 changes: 53 additions & 0 deletions src/utils/seoConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Type imports
import type { ManifestOptions } from "vite-plugin-pwa"

/**
* Defines the default SEO configuration for the website.
*/
export const seoConfig = {
baseURL: "https://lavelada.es/", // Production URL.
description:
"Web Oficial de La Velada del Año IV, evento de boxeo entre streamers y creadores de contenido, organizado por Ibai Llanos.",
type: "website",
image: {
url: "https://lavelada.es/og.png",
alt: "La Velada",
width: 705,
height: 606,
},
siteName: "La Velada",
twitter: {
card: "summary_large_image",
},
}

/**
* Defines the configuration for PWA webmanifest.
*/
export const manifest: Partial<ManifestOptions> = {
name: "La Velada",
short_name: "La Velada",
description:
"Web Oficial de La Velada del Año IV, evento de boxeo entre streamers y creadores de contenido, organizado por Ibai Llanos.",
theme_color: "#d5ff00",
background_color: "#d5ff00",
display: "fullscreen",
icons: [
{
src: "/img/icons/favicon-192x192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "/img/icons/favicon-512x512.png",
sizes: "512x512",
type: "image/png",
},
{
src: "/img/icons/favicon-512x512.png",
sizes: "512x512",
type: "image/png",
purpose: "any maskable",
},
],
}

0 comments on commit af4135e

Please sign in to comment.