1
0
mirror of https://github.com/sendevia/website.git synced 2026-03-05 23:32:45 +08:00

refactor: improve code readability by formatting style

This commit is contained in:
2025-11-18 15:32:29 +08:00
parent e247341e93
commit e512e79932
4 changed files with 60 additions and 12 deletions

View File

@@ -34,7 +34,9 @@ if (typeof window !== "undefined") {
<div id="header-impression-noise"></div>
<div
id="header-impression-image"
:style="{ backgroundImage: frontmatter.impression ? `url('${frontmatter.impression}')` : `url('${defaultImpression}')` }"
:style="{
backgroundImage: frontmatter.impression ? `url('${frontmatter.impression}')` : `url('${defaultImpression}')`,
}"
:impression-color="frontmatter.color"
loading="lazy"
></div>
@@ -83,7 +85,12 @@ header {
z-index: 1;
#header-hero-headline {
@include mixin.typescale-style("display-large", $font-size: 90rem, $line-height: 90rem, $font-variation-settings: "wght" 700);
@include mixin.typescale-style(
"display-large",
$font-size: 90rem,
$line-height: 90rem,
$font-variation-settings: "wght" 700
);
width: 100%;
@@ -175,11 +182,21 @@ header {
padding: 5vw;
#header-hero-headline {
@include mixin.typescale-style("display-large", $font-size: 7vw, $line-height: 7vw, $font-variation-settings: "wght" 500);
@include mixin.typescale-style(
"display-large",
$font-size: 7vw,
$line-height: 7vw,
$font-variation-settings: "wght" 500
);
}
#header-hero-subtitle {
@include mixin.typescale-style("display-small", $font-size: 18rem, $line-height: 20rem, $font-variation-settings: "wght" 500);
@include mixin.typescale-style(
"display-small",
$font-size: 18rem,
$line-height: 20rem,
$font-variation-settings: "wght" 500
);
}
}
}
@@ -193,7 +210,12 @@ header {
width: 100%;
#header-hero-headline {
@include mixin.typescale-style("display-large", $font-size: 8vw, $line-height: 8vw, $font-variation-settings: "wght" 600);
@include mixin.typescale-style(
"display-large",
$font-size: 8vw,
$line-height: 8vw,
$font-variation-settings: "wght" 600
);
}
#header-hero-subtitle {
@@ -211,13 +233,23 @@ header {
padding: 30px;
#header-hero-headline {
@include mixin.typescale-style("display-large", $font-size: 40rem, $line-height: 40rem, $font-variation-settings: "wght" 700);
@include mixin.typescale-style(
"display-large",
$font-size: 40rem,
$line-height: 40rem,
$font-variation-settings: "wght" 700
);
word-break: break-word;
}
#header-hero-subtitle {
@include mixin.typescale-style("display-small", $font-size: 15rem, $line-height: 17rem, $font-variation-settings: "wght" 400);
@include mixin.typescale-style(
"display-small",
$font-size: 15rem,
$line-height: 17rem,
$font-variation-settings: "wght" 400
);
}
}
}

View File

@@ -60,11 +60,16 @@ export function useAllPosts(asRef = false) {
const name = filename.replace(/\.mdx?$/, "").replace(/\.md$/, "");
const url = `/posts/${encodeURIComponent(name)}.html`;
const content = mod.excerpt || mod.excerpt?.text || mod.attributes?.excerpt || (typeof mod.default === "string" ? mod.default : undefined);
const content =
mod.excerpt ||
mod.excerpt?.text ||
mod.attributes?.excerpt ||
(typeof mod.default === "string" ? mod.default : undefined);
const po: Data = {
title: frontmatter.title || name,
description: frontmatter.description || frontmatter.excerpt || (typeof content === "string" ? content.slice(0, 160) : "") || "",
description:
frontmatter.description || frontmatter.excerpt || (typeof content === "string" ? content.slice(0, 160) : "") || "",
date: dateStr,
timestamp,
url,

View File

@@ -1,6 +1,7 @@
.layout-content-enter-active {
transition: opacity var(--md-sys-motion-spring-fast-effect-duration) var(--md-sys-motion-spring-fast-effect),
transform var(--md-sys-motion-spring-fast-spatial-duration) var(--md-sys-motion-spring-fast-spatial) var(--md-sys-motion-duration-short1);
transform var(--md-sys-motion-spring-fast-spatial-duration) var(--md-sys-motion-spring-fast-spatial)
var(--md-sys-motion-duration-short1);
}
.layout-content-leave-active {

View File

@@ -8,7 +8,12 @@ import { CorePalette, hexFromArgb, Blend, argbFromHex } from "@material/material
* @param tones 调色板的色相
* @return CorePalette Object
*/
function createPaletteProvider(argbColor: number, name: string, append: "a1" | "a2" | "a3" | "n1" | "n2" | "error", tones: number[]) {
function createPaletteProvider(
argbColor: number,
name: string,
append: "a1" | "a2" | "a3" | "n1" | "n2" | "error",
tones: number[]
) {
const palette = CorePalette.of(argbColor);
return {
rawPalette: {
@@ -83,7 +88,12 @@ export async function generateColorPalette(baseColor: number) {
setPalette(paletteObject);
}),
...harmonizedPalettes.map((palette) => {
const paletteObject = createPaletteProvider(Blend.harmonize(argbFromHex(palette.color), baseColor), palette.name, palette.append, palette.tones);
const paletteObject = createPaletteProvider(
Blend.harmonize(argbFromHex(palette.color), baseColor),
palette.name,
palette.append,
palette.tones
);
setPalette(paletteObject);
}),
];