mirror of
https://github.com/m1ngsama/FUJI.git
synced 2025-12-25 02:56:38 +00:00
Merge branch 'dev' into feature-nextui
This commit is contained in:
commit
1de0298e6c
6 changed files with 101 additions and 51 deletions
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
|
@ -2,7 +2,7 @@ name: build-deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["main", "feature-*"]
|
branches: ["main", "dev", "feature-*"]
|
||||||
paths-ignore: # 忽略的文件
|
paths-ignore: # 忽略的文件
|
||||||
- "README.md"
|
- "README.md"
|
||||||
- "LICENSE"
|
- "LICENSE"
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
---
|
---
|
||||||
import { formatDate } from "../utils"
|
import { formatDate } from "../utils"
|
||||||
const { title, href, cover, tags, date } = Astro.props
|
const { title, href, cover, tags, date } = Astro.props
|
||||||
|
import { fixImage } from "../utils/image"
|
||||||
const dateFormatted = formatDate(date)
|
const dateFormatted = formatDate(date)
|
||||||
const type = tags?.[0] ?? "默认"
|
const type = tags?.[0] ?? "默认"
|
||||||
|
|
||||||
const image = cover ? cover : "https://oss.nbtca.space/CA-logo.svg"
|
let image = cover?.url ?? cover ?? "https://oss.nbtca.space/CA-logo.svg"
|
||||||
|
if (image.startsWith("./")) {
|
||||||
|
image = await fixImage(image, href)
|
||||||
|
}
|
||||||
|
|
||||||
const label = `${title} - ${type} - 发表时间 ${dateFormatted}`
|
const label = `${title} - ${type} - 发表时间 ${dateFormatted}`;
|
||||||
---
|
---
|
||||||
|
|
||||||
<li
|
<li
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,16 @@
|
||||||
---
|
---
|
||||||
import { formatDate } from "../utils"
|
import { formatDate } from "../utils"
|
||||||
const { title, href, cover, tags, date, level } = Astro.props
|
const { title, href, cover, tags, date, level } = Astro.props
|
||||||
|
import { fixImage } from "../utils/image"
|
||||||
|
|
||||||
const dateFormatted = formatDate(date)
|
const dateFormatted = formatDate(date)
|
||||||
const type = tags[0]
|
const type = tags[0]
|
||||||
const label = `${title} - ${type} - 发表时间 ${dateFormatted}`;
|
const label = `${title} - ${type} - 发表时间 ${dateFormatted}`
|
||||||
|
let image = cover?.url ?? cover ?? "https://oss.nbtca.space/CA-logo.svg"
|
||||||
|
if (image.startsWith("./")) {
|
||||||
|
image = await fixImage(image, href)
|
||||||
|
}
|
||||||
|
|
||||||
// level 1: hero
|
// level 1: hero
|
||||||
// level 2: 2up
|
// level 2: 2up
|
||||||
// level 3: 3up
|
// level 3: 3up
|
||||||
|
|
@ -12,16 +18,34 @@ const label = `${title} - ${type} - 发表时间 ${dateFormatted}`;
|
||||||
|
|
||||||
<li
|
<li
|
||||||
role="listitem"
|
role="listitem"
|
||||||
class:list={["tile-item", "nr-scroll-animation", { "item-hero": level === "1", "item-2up": level === "2", "item-3up": level === "3" }]}
|
class:list={[
|
||||||
|
"tile-item",
|
||||||
|
"nr-scroll-animation",
|
||||||
|
{
|
||||||
|
"item-hero": level === "1",
|
||||||
|
"item-2up": level === "2",
|
||||||
|
"item-3up": level === "3",
|
||||||
|
},
|
||||||
|
]}
|
||||||
style="--nr-animation-transform-y:20%;"
|
style="--nr-animation-transform-y:20%;"
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href={href}
|
href={href}
|
||||||
class:list={["tile", "large-load", "medium-load", "small-load", { "tile-hero": level === "1", "tile-2up": level === "2", "tile-3up": level === "3" }]}
|
class:list={[
|
||||||
|
"tile",
|
||||||
|
"large-load",
|
||||||
|
"medium-load",
|
||||||
|
"small-load",
|
||||||
|
{
|
||||||
|
"tile-hero": level === "1",
|
||||||
|
"tile-2up": level === "2",
|
||||||
|
"tile-3up": level === "3",
|
||||||
|
},
|
||||||
|
]}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
>
|
>
|
||||||
<div class="tile__media" aria-hidden="true">
|
<div class="tile__media" aria-hidden="true">
|
||||||
<img class="cover image" src={cover} alt="lt" />
|
<img class="cover image" src={image} alt="lt" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tile__description" aria-hidden="true">
|
<div class="tile__description" aria-hidden="true">
|
||||||
|
|
@ -29,7 +53,9 @@ const label = `${title} - ${type} - 发表时间 ${dateFormatted}`;
|
||||||
<div class="tile__category">{type}</div>
|
<div class="tile__category">{type}</div>
|
||||||
<div class="tile__headline">{title}</div>
|
<div class="tile__headline">{title}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tile__timestamp icon-hide icon icon-before icon-clock">{dateFormatted}</div>
|
<div class="tile__timestamp icon-hide icon icon-before icon-clock">
|
||||||
|
{dateFormatted}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ Blogs.sort(
|
||||||
href={post.url}
|
href={post.url}
|
||||||
date={post.frontmatter.pubDate}
|
date={post.frontmatter.pubDate}
|
||||||
tags={post.frontmatter.tags}
|
tags={post.frontmatter.tags}
|
||||||
cover={post.frontmatter.cover.url}
|
cover={post.frontmatter.cover}
|
||||||
level="1"
|
level="1"
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
@ -44,7 +44,7 @@ Blogs.sort(
|
||||||
href={post.url}
|
href={post.url}
|
||||||
date={post.frontmatter.pubDate}
|
date={post.frontmatter.pubDate}
|
||||||
tags={post.frontmatter.tags}
|
tags={post.frontmatter.tags}
|
||||||
cover={post.frontmatter.cover.url}
|
cover={post.frontmatter.cover}
|
||||||
level="2"
|
level="2"
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
@ -60,7 +60,7 @@ Blogs.sort(
|
||||||
href={post.url}
|
href={post.url}
|
||||||
date={post.frontmatter.pubDate}
|
date={post.frontmatter.pubDate}
|
||||||
tags={post.frontmatter.tags}
|
tags={post.frontmatter.tags}
|
||||||
cover={post.frontmatter.cover.url}
|
cover={post.frontmatter.cover}
|
||||||
level="3"
|
level="3"
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
@ -84,7 +84,7 @@ Blogs.sort(
|
||||||
href={post.url}
|
href={post.url}
|
||||||
date={post.frontmatter.pubDate}
|
date={post.frontmatter.pubDate}
|
||||||
tags={post.frontmatter.tags}
|
tags={post.frontmatter.tags}
|
||||||
cover={post.frontmatter.cover.url}
|
cover={post.frontmatter.cover}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
@ -97,6 +97,7 @@ Blogs.sort(
|
||||||
href={post.url}
|
href={post.url}
|
||||||
date={post.frontmatter.pubDate}
|
date={post.frontmatter.pubDate}
|
||||||
tags={post.frontmatter.tags}
|
tags={post.frontmatter.tags}
|
||||||
|
cover={post.frontmatter.cover}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
20
src/utils/image.ts
Normal file
20
src/utils/image.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { getImage } from "astro:assets"
|
||||||
|
|
||||||
|
export async function fixImage(image: string, href: string) {
|
||||||
|
try {
|
||||||
|
const sliceHref = href.slice(0, href.lastIndexOf("/") + 1)// get the dir of the current page(remove filename)
|
||||||
|
const imageLocation = await import(
|
||||||
|
/* @vite-ignore */ `/src/pages${sliceHref}${image.slice(1)}`
|
||||||
|
)// static import of the image
|
||||||
|
image = imageLocation.default
|
||||||
|
return (
|
||||||
|
await getImage({ // resolve the images
|
||||||
|
src: image,
|
||||||
|
inferSize: true,
|
||||||
|
})
|
||||||
|
).src
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue