Skip to content

Commit

Permalink
feat: different logos for staging and dev
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 8, 2023
1 parent c647a87 commit 0297ed8
Show file tree
Hide file tree
Showing 19 changed files with 64 additions and 63 deletions.
3 changes: 1 addition & 2 deletions components/nav/NavFooter.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { buildInfo } from 'virtual:build-info'
const buildInfo = useRuntimeConfig().public.buildInfo
const timeAgoOptions = useTimeAgoOptions()
const buildTimeDate = new Date(buildInfo.time)
Expand Down
4 changes: 1 addition & 3 deletions components/nav/NavTitle.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<script setup lang="ts">
import { buildInfo } from 'virtual:build-info'
const { env } = buildInfo
const { env } = useBuildInfo()
</script>

<template>
Expand Down
6 changes: 6 additions & 0 deletions composables/about.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { BuildInfo } from '~~/types'

export interface Team {
github: string
display: string
Expand Down Expand Up @@ -31,3 +33,7 @@ export const teams: Team[] = [
mastodon: '[email protected]',
},
].sort(() => Math.random() - 0.5)

export function useBuildInfo() {
return useRuntimeConfig().public.buildInfo as BuildInfo
}
2 changes: 1 addition & 1 deletion composables/setups.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Directions } from 'vue-i18n-routing'
import { buildInfo } from 'virtual:build-info'
import type { LocaleObject } from '#i18n'

export function setupPageHeader() {
const { locale, locales, t } = useI18n()
const buildInfo = useBuildInfo()

const localeMap = (locales.value as LocaleObject[]).reduce((acc, l) => {
acc[l.code!] = l.dir ?? 'auto'
Expand Down
30 changes: 30 additions & 0 deletions modules/build-env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { createResolver, defineNuxtModule } from '@nuxt/kit'
import { getEnv, version } from '../config/env'
import type { BuildInfo } from '~/types'

const { resolve } = createResolver(import.meta.url)

export default defineNuxtModule({
meta: {
name: 'elk:build-env',
},
async setup(_options, nuxt) {
const { env, commit, branch } = await getEnv()
const buildInfo: BuildInfo = {
version,
time: +Date.now(),
commit,
branch,
env,
}

nuxt.options.runtimeConfig.public.env = env
nuxt.options.runtimeConfig.public.buildInfo = buildInfo

nuxt.options.nitro.publicAssets ||= nuxt.options.nitro.publicAssets || []
if (env === 'canary' || env === 'preview')
nuxt.options.nitro.publicAssets.push({ dir: resolve('../public-staging') })
else if (env === 'dev')
nuxt.options.nitro.publicAssets.push({ dir: resolve('../public-dev') })
},
})
33 changes: 0 additions & 33 deletions modules/build-info.ts

This file was deleted.

12 changes: 4 additions & 8 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { createResolver } from '@nuxt/kit'
import Inspect from 'vite-plugin-inspect'
import { isCI, isDevelopment } from 'std-env'
import { isPreview } from './config/env'
import { i18n } from './config/i18n'
import { pwa } from './config/pwa'
import { isPreview } from './config/env'

const { resolve } = createResolver(import.meta.url)
import type { BuildInfo } from './types'

export default defineNuxtConfig({
typescript: {
Expand Down Expand Up @@ -93,7 +91,8 @@ export default defineNuxtConfig({
inviteToken: '',
},
public: {
env: '', // set in build-info module
env: '', // set in build-env module
buildInfo: {} as BuildInfo, // set in build-env module
pwaEnabled: !isDevelopment || process.env.VITE_DEV_PWA === 'true',
translateApi: '',
defaultServer: 'mas.to',
Expand All @@ -112,9 +111,6 @@ export default defineNuxtConfig({
},
},
nitro: {
publicAssets: [
...(!isCI || isPreview ? [{ dir: resolve('./public-dev') }] : []),
],
prerender: {
crawlLinks: false,
routes: ['/'],
Expand Down
3 changes: 1 addition & 2 deletions pages/settings/about/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { buildInfo } from 'virtual:build-info'
const buildInfo = useBuildInfo()
const { t } = useI18n()
useHeadFixed({
Expand Down
Binary file modified public-dev/apple-touch-icon.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 modified public-dev/favicon.ico
Binary file not shown.
18 changes: 9 additions & 9 deletions public-dev/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public-dev/pwa-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 modified public-dev/pwa-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-staging/apple-touch-icon.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-staging/favicon.ico
Binary file not shown.
11 changes: 11 additions & 0 deletions public-staging/logo.svg
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-staging/pwa-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-staging/pwa-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions shims.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/// <reference types="@types/wicg-file-system-access" />
/// <reference types="vite-plugin-pwa/info" />
/// <reference types="vite-plugin-pwa/client" />

declare module 'virtual:build-info' {
import type { BuildInfo } from '~/types'
export const buildInfo: BuildInfo
}

0 comments on commit 0297ed8

Please sign in to comment.