mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-03-24 15:05:42 -05:00
feat: show banner of notes
This commit is contained in:
parent
c5d97db000
commit
6227ecaf16
@ -21,6 +21,7 @@ export const defaultContentPageLayout: PageLayout = {
|
|||||||
Component.ArticleTitle(),
|
Component.ArticleTitle(),
|
||||||
Component.ContentMeta(),
|
Component.ContentMeta(),
|
||||||
Component.TagList(),
|
Component.TagList(),
|
||||||
|
Component.Banner(),
|
||||||
],
|
],
|
||||||
left: [
|
left: [
|
||||||
Component.PageTitle(),
|
Component.PageTitle(),
|
||||||
|
|||||||
28
quartz/components/Banner.tsx
Normal file
28
quartz/components/Banner.tsx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
import style from "./styles/banner.scss"
|
||||||
|
|
||||||
|
export default (() => {
|
||||||
|
function Banner({ fileData }: QuartzComponentProps) {
|
||||||
|
if (fileData.frontmatter?.banner && typeof fileData.frontmatter?.banner === "string") {
|
||||||
|
const src = fileData.frontmatter.banner.startsWith("http")
|
||||||
|
? fileData.frontmatter.banner
|
||||||
|
: "/" + fileData.frontmatter.banner
|
||||||
|
const banner_x = fileData.frontmatter.banner_x
|
||||||
|
? Number(fileData.frontmatter.banner_x) * 100 + "%"
|
||||||
|
: "50%"
|
||||||
|
const banner_y = fileData.frontmatter.banner_y
|
||||||
|
? Number(fileData.frontmatter.banner_y) * 100 + "%"
|
||||||
|
: "50%"
|
||||||
|
return (
|
||||||
|
<div class="banner">
|
||||||
|
<img src={src} style={"object-position: " + banner_x + " " + banner_y}></img>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return <></>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Banner.css = style
|
||||||
|
|
||||||
|
return Banner
|
||||||
|
}) satisfies QuartzComponentConstructor
|
||||||
@ -20,6 +20,7 @@ import MobileOnly from "./MobileOnly"
|
|||||||
import RecentNotes from "./RecentNotes"
|
import RecentNotes from "./RecentNotes"
|
||||||
import Breadcrumbs from "./Breadcrumbs"
|
import Breadcrumbs from "./Breadcrumbs"
|
||||||
import Comments from "./Comments"
|
import Comments from "./Comments"
|
||||||
|
import Banner from "./Banner"
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ArticleTitle,
|
ArticleTitle,
|
||||||
@ -44,4 +45,5 @@ export {
|
|||||||
NotFound,
|
NotFound,
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
Comments,
|
Comments,
|
||||||
|
Banner,
|
||||||
}
|
}
|
||||||
|
|||||||
14
quartz/components/styles/banner.scss
Normal file
14
quartz/components/styles/banner.scss
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
.banner {
|
||||||
|
max-height: 300px;
|
||||||
|
height: auto;
|
||||||
|
aspect-ratio: 16/9;
|
||||||
|
width: 100%;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
img {
|
||||||
|
object-fit: cover;
|
||||||
|
max-width: none;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user