Merge pull request #3 from cheeaun/main

Update from main
This commit is contained in:
Chee Aun 2022-12-15 14:48:02 +08:00 committed by GitHub
commit ab5f53273f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

View file

@ -81,6 +81,7 @@ function Media({ media, showOriginal, onClick }) {
alt={description}
width={width}
height={height}
loading="lazy"
style={
!showOriginal && {
backgroundColor:
@ -163,6 +164,7 @@ function Media({ media, showOriginal, onClick }) {
alt={description}
width={width}
height={height}
loading="lazy"
/>
)}
</div>
@ -215,6 +217,7 @@ function Card({ card }) {
src={image}
width={width}
height={height}
loading="lazy"
alt=""
onError={() => {
this.style.display = 'none';
@ -245,6 +248,7 @@ function Card({ card }) {
width={width}
height={height}
alt={title || description}
loading="lazy"
style={{
height: 'auto',
aspectRatio: `${width}/${height}`,

View file

@ -186,6 +186,24 @@ export default ({ onClose }) => {
</a>
.
</p>
{__BUILD_TIME__ && (
<p>
Last build:{' '}
<relative-time datetime={new Date(__BUILD_TIME__).toISOString()} />{' '}
{__COMMIT_HASH__ && (
<>
(
<a
href={`https://github.com/cheeaun/phanpy/commit/${__COMMIT_HASH__}`}
target="_blank"
>
<code>{__COMMIT_HASH__}</code>
</a>
)
</>
)}
</p>
)}
</div>
);
};

View file

@ -1,9 +1,16 @@
import preact from '@preact/preset-vite';
import { execSync } from 'child_process';
import { resolve } from 'path';
import { defineConfig, splitVendorChunkPlugin } from 'vite';
const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
// https://vitejs.dev/config/
export default defineConfig({
define: {
__BUILD_TIME__: JSON.stringify(Date.now()),
__COMMIT_HASH__: JSON.stringify(commitHash),
},
plugins: [preact(), splitVendorChunkPlugin()],
build: {
sourcemap: true,