From dd0f76e3d0d44ce654bac467754383c7b2b0177d Mon Sep 17 00:00:00 2001 From: Alexander Heimbuch Date: Wed, 1 Jan 2025 16:57:25 +0100 Subject: [PATCH] chore(page): use commit hash for chache busting --- apps/page/astro.config.mjs | 8 ++++++ apps/page/src/features/PageFooter.vue | 15 ++++------ apps/page/src/i18n/messages.ts | 4 +-- apps/page/src/logic/sagas/search.sagas.ts | 35 +---------------------- apps/page/src/middleware/store.ts | 5 +++- 5 files changed, 20 insertions(+), 47 deletions(-) diff --git a/apps/page/astro.config.mjs b/apps/page/astro.config.mjs index 53b70a7e6..7ec427d15 100644 --- a/apps/page/astro.config.mjs +++ b/apps/page/astro.config.mjs @@ -2,6 +2,9 @@ import { defineConfig } from 'astro/config'; import cloudflare from '@astrojs/cloudflare'; import vue from '@astrojs/vue'; import tailwind from '@astrojs/tailwind'; +import * as child from 'child_process'; + +const commitHash = child.execSync('git rev-parse --short HEAD').toString().trim(); // https://astro.build/config export default defineConfig({ @@ -11,5 +14,10 @@ export default defineConfig({ enabled: true } }), + vite: { + define: { + 'import.meta.env.VITE_COMMIT_HASH': JSON.stringify(commitHash) + } + }, integrations: [vue({ appEntrypoint: '/src/app' }), tailwind()] }); diff --git a/apps/page/src/features/PageFooter.vue b/apps/page/src/features/PageFooter.vue index e3a3ca295..c2d4c2321 100644 --- a/apps/page/src/features/PageFooter.vue +++ b/apps/page/src/features/PageFooter.vue @@ -3,10 +3,10 @@ class="w-full bg-gray-800 p-6 mt-16 text-gray-100 font-extralight text-sm" >
-
+
{{ t('FOOTER.COPYRIGHT', { copyright: state.copyright }) }}
-
+ -
+
{{ t('FOOTER.CREATED_WITH', { name: 'Podlove Lux', buildDate }) }}{{ t('FOOTER.CREATED_WITH', { name: 'Podlove Lux', version: state.version }) }}
@@ -34,7 +34,6 @@ diff --git a/apps/page/src/i18n/messages.ts b/apps/page/src/i18n/messages.ts index ef12ef9d6..6062bef38 100644 --- a/apps/page/src/i18n/messages.ts +++ b/apps/page/src/i18n/messages.ts @@ -11,7 +11,7 @@ const en = { }, FOOTER: { COPYRIGHT: ({ copyright }: { copyright: string }) => `© ${copyright}`, - CREATED_WITH: ({ name, buildDate }: { name: string, buildDate: string }) => `Created with ${name} on ${buildDate}`, + CREATED_WITH: ({ name, version }: { name: string, version: string }) => `Created with ${name} [${version}]`, CONTACT: ({ name }: { name: string }) => `Contact: ${name}`, }, EPISODE: { @@ -89,7 +89,7 @@ const de: typeof en = { }, FOOTER: { COPYRIGHT: ({ copyright }: { copyright: string }) => `© ${copyright}`, - CREATED_WITH: ({ name, buildDate }: { name: string, buildDate: string }) => `Erstellt mit ${name} am ${buildDate}`, + CREATED_WITH: ({ name, version }: { name: string, version: string }) => `Erstellt mit ${name} [${version}]`, CONTACT: ({ name }: { name: string }) => `Kontakt: ${name}`, }, EPISODE: { diff --git a/apps/page/src/logic/sagas/search.sagas.ts b/apps/page/src/logic/sagas/search.sagas.ts index a8fa32f74..23b6b046b 100644 --- a/apps/page/src/logic/sagas/search.sagas.ts +++ b/apps/page/src/logic/sagas/search.sagas.ts @@ -11,8 +11,7 @@ import type { } from '../store/stores/search.store'; import { actions } from '../store'; import { resolveTranscripts } from '../data/feed-parser'; -import type { Episode, Person, Transcript } from '../../types/feed.types'; -// import { findPerson } from '../../lib/persons'; +import type { Episode, Transcript } from '../../types/feed.types'; import { proxy, addQueryparams } from '../../lib/url'; import * as indexeddb from '../../lib/indexeddb'; @@ -20,7 +19,6 @@ export default ({ selectVisible, selectInitialized, selectEpisodes, - // selectContributors, selectResults, selectSelectedResult, selectCacheKey, @@ -29,7 +27,6 @@ export default ({ selectVisible: (input: any) => boolean; selectInitialized: (input: any) => boolean; selectEpisodes: (input: any) => Episode[]; - // selectContributors: (input: any) => Person[]; selectResults: (input: any) => { id: string | number }[]; selectSelectedResult: (input: any) => string | null; selectCacheKey: (input: any) => string | null; @@ -37,7 +34,6 @@ export default ({ }) => { const EPISODES = fuzzySearch.SearcherFactory.createDefaultSearcher(); const TRANSCRIPTS = fuzzySearch.SearcherFactory.createDefaultSearcher(); - // const CONTRIBUTORS = fuzzySearch.SearcherFactory.createDefaultSearcher(); function* createEpisodesSearchIndex(episodes: Episode[]) { const results = episodes.map((episode) => ({ @@ -142,31 +138,6 @@ export default ({ yield put(actions.search.initialize('transcripts')); } - // function* createContributorsSearchIndex(contributors: Person[], episodes: Episode[]) { - // const results = contributors.map((contributor) => { - // const attendedEpisodes = episodes.filter((episode) => - // findPerson(episode.contributors, contributor.id) - // ); - - // return { - // ...contributor, - // id: `contributor-${contributor.id}`, - // episode: { - // title: attendedEpisodes.map(({ title }) => title).join(' '), - // description: attendedEpisodes.map(({ description }) => description).join(' ') - // } - // }; - // }); - - // CONTRIBUTORS.indexEntities( - // flattenDeep(results), - // (e: any) => e.id, - // (e: any) => [e.episode.title, e.episode.description] - // ); - - // yield put(actions.search.initialize('contributors')); - // } - function* createSearchIndex() { const episodes: Episode[] = yield select(selectEpisodes); // const contributors: Person[] = yield select(selectContributors); @@ -186,10 +157,6 @@ export default ({ (match) => match.entity ) as unknown as EpisodeResult[]; - // const contributors = CONTRIBUTORS.getMatches( - // new fuzzySearch.Query(payload || '', 5) - // ).matches.map((match) => match.entity) as unknown as Person[]; - const transcripts = TRANSCRIPTS.getMatches( new fuzzySearch.Query(payload || '', 5, 0.1) ).matches.map((match) => match.entity) as unknown as TranscriptResult[]; diff --git a/apps/page/src/middleware/store.ts b/apps/page/src/middleware/store.ts index e3ba355dc..84053cb4b 100644 --- a/apps/page/src/middleware/store.ts +++ b/apps/page/src/middleware/store.ts @@ -5,7 +5,10 @@ import { getRequestHeader } from '../lib/middleware'; import parseFeed from '../logic/data/feed-parser'; import type { Podcast } from '../types/feed.types'; import { createHash } from '../lib/caching'; -import { version } from '../../package.json'; + +const version = import.meta.env.VITE_COMMIT_HASH; + +console.log({ version }) export const initializeStore = defineMiddleware(async ({ request, params }, next) => { const locale = getRequestHeader(request, 'accept-language', 'en-US');