Skip to content

Commit

Permalink
Add PWA support
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman committed Oct 15, 2023
1 parent eea7b88 commit 582cd19
Show file tree
Hide file tree
Showing 7 changed files with 1,413 additions and 1,369 deletions.
11 changes: 11 additions & 0 deletions composables/useMetaThemeColor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default function () {
const update = () => {
const themeColor = getComputedStyle(document.documentElement).getPropertyValue(
'--color-ui-gray-800'
);

document.querySelector('meta[name=theme-color]').setAttribute('content', themeColor);
};

return { update };
}
15 changes: 13 additions & 2 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ module.exports = {
},
{ rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png' },
{ rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png' },
{ rel: 'manifest', href: '/site.webmanifest' },
{ rel: 'mask-icon', href: '/safari-pinned-tab.svg', color: '#5bbad5' },
],
script: [],
Expand All @@ -86,7 +85,7 @@ module.exports = {
buildModules: ['@nuxt/postcss8', '@nuxtjs/composition-api/module', '@pinia/nuxt'],

// Modules: https://go.nuxtjs.dev/config-modules
modules: ['@nuxt/content'],
modules: ['@nuxtjs/pwa', '@nuxt/content'],

content: {
markdown: {
Expand All @@ -96,6 +95,18 @@ module.exports = {
},
},

pwa: {
manifest: {
name: 'Showcode',
short_name: 'Showcode',
description: 'Generate beautiful images of code.',
useWebmanifestExtension: false,
},
workbox: {
enabled: true,
},
},

// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
extend(config) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@nuxt/content": "^1.15.1",
"@nuxt/postcss8": "^1.1.3",
"@nuxtjs/composition-api": "^0.31.0",
"@nuxtjs/pwa": "^3.3.5",
"@panzoom/panzoom": "^4.4.4",
"@pinia/nuxt": "^0.1.8",
"@stevebauman/shiki": "^0.10.4",
Expand Down
6 changes: 5 additions & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ import { usePreferredColorScheme } from '@vueuse/core';
import useCurrentTab from '@/composables/useCurrentTab';
import useProjectStores from '@/composables/useProjectStores';
import useTemplateStore from '@/composables/useTemplateStore';
import useMetaThemeColor from '@/composables/useMetaThemeColor';
import useApplicationStore from '@/composables/useApplicationStore';
import { XIcon, PlusIcon, SunIcon, MoonIcon, ImageIcon } from 'vue-feather-icons';
import { computed, onMounted, ref, useContext, watch } from '@nuxtjs/composition-api';
import { computed, nextTick, onMounted, ref, useContext, watch } from '@nuxtjs/composition-api';
export default {
components: {
Expand All @@ -147,6 +148,8 @@ export default {
const templates = useTemplateStore();
const { update: updateMetaThemeColor } = useMetaThemeColor();
const { setTabFromProject, projectIsActive, currentTab } = useCurrentTab();
const colorScheme = usePreferredColorScheme();
Expand Down Expand Up @@ -279,6 +282,7 @@ export default {
}
watch(colorScheme, (scheme) => (colorMode.value = scheme));
watch(colorMode, () => nextTick(updateMetaThemeColor), { immediate: true });
});
$bus.$on('alert', (variant, message) => (alert.value = { variant, message }));
Expand Down
Binary file added static/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 0 additions & 19 deletions static/site.webmanifest

This file was deleted.

Loading

0 comments on commit 582cd19

Please sign in to comment.