Skip to content

Commit

Permalink
字体压缩有问题,先回退
Browse files Browse the repository at this point in the history
  • Loading branch information
rebron1900 committed Sep 14, 2024
1 parent 6c2b0d5 commit 305079b
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 1,567 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"astro-compress": "^2.3.1",
"astro-remote": "^0.3.3",
"cheerio": "^1.0.0",
"fontmin": "^1.1.0",
"fuse.js": "^7.0.0",
"html-parse-stringify": "^3.0.1",
"mapbox-gl": "^3.6.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Menu.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import MenuSearch from './MenuSearch.astro';
import MenuTaxonomy from './MenuTaxonomy.astro';
import MenuTheme from './MenuTheme';
const { site, post } = Astro.props;
const { site, title } = Astro.props;
---

<nav>
<Brand />
<MenuSearch />
<MenuTheme client:load />
<MenuNav post={post} />
<MenuNav title={title} />
<MenuTaxonomy />
<MenuOther />
</nav>
8 changes: 4 additions & 4 deletions src/components/MenuNav.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { settings } from '../data/ghost-store';
const { post } = Astro.props;
const { title } = Astro.props;
---

<ul class="book-menu-nav" transition:name="fdsafds">
Expand All @@ -10,11 +10,11 @@ const { post } = Astro.props;
<span class=""></span>
<ul>
{
post && post.type === 'post' && (
<li transition:name={Astro.url.pathname == post.slug ? post.slug : ''}>
title && (
<li transition:name="page-current">
<span class={`menu-flag current ellipsis`} />
<a href="javascript:void(0)" style="display: block;" class="menu-flag current">
{post.title}
{title}
</a>
</li>
)
Expand Down
24 changes: 12 additions & 12 deletions src/data/ghost-store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getSettings, getPosts, getAllTags, getAllPages, getAllPosts, getNeodb, getFlux, getMemos, getAllAuthors } from '../utils/api';
import { atom } from 'nanostores';
import { minfont } from '../utils/help';
// import { minfont } from '../utils/help';

const settingsStore = atom(await getSettings());
const postsStore = atom(await getPosts());
Expand All @@ -22,15 +22,15 @@ export const flux = fluxStore.get();
export const memos = memosStore.get();
export const authors = authorsStore.get();

export function buildFonts() {
const titleText = postsAll
.map(function (item) {
let tags = item.tags.map((tag) => tag.name).join(',');
let desc = item.excerpt != null ? item.excerpt.substring(0, 100) : '';
return item.title + desc + tags;
})
.join(',');
minfont(titleText);
}
// export function buildFonts() {
// const titleText = postsAll
// .map(function (item) {
// let tags = item.tags.map((tag) => tag.name).join(',');
// let desc = item.excerpt != null ? item.excerpt.substring(0, 100) : '';
// return item.title + desc + tags;
// })
// .join(',');
// minfont(titleText);
// }

buildFonts();
// buildFonts();
2 changes: 0 additions & 2 deletions src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// import lib
import type { Tag } from '@ts-ghost/content-api';
import { settings } from '../data/ghost-store';
// import components
// import styles
import '../styles/book.scss';
// ...
const { post } = Astro.props;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const tocHtml = tocGen(await post.html);

<Header slot="header" title={post.title} />

<Menu slot="menu" post={post} />
<Menu slot="menu" title={post.title} />
<article slot="content" class="markdown book-article">
<h1 class="book-title">
{post.title}
Expand Down
7 changes: 5 additions & 2 deletions src/pages/tag/[slug]/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@ export async function getStaticPaths({ paginate }: GetStaticPathsOptions) {
return tags.flatMap((tag) => {
return paginate(tag.posts, {
params: { slug: tag.slug },
props: {
tag
},
pageSize: 10
});
});
}
const { page } = Astro.props;
const { page, tag } = Astro.props;
---

<BaseLayout>
<Head slot="head" site={settings} title={settings?.title + ' | ' + settings?.description} />

<Header slot="header" title={settings?.title} />

<Menu slot="menu" />
<Menu slot="menu" title={tag.name} />

<List slot="content" page={page} isFeature={false} />

Expand Down
32 changes: 16 additions & 16 deletions src/utils/help.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash-es'; // 获取一个svg字符串
import Fontmin from 'fontmin';
// import Fontmin from 'fontmin-esm';
export function getSvg(name: string = '', viewbox: string = '0 0 24 24', classes: string = 'book-icon'): string {
return `
<svg viewBox="${viewbox}" aria-hidden="true"${classes ? ` class="${classes}"` : ''}>
Expand Down Expand Up @@ -76,19 +76,19 @@ export function normalizeData(data: string): string | null {
}
}

export function minfont(titleText: string) {
const fontmin = new Fontmin()
.src('src/font/SmileySans.ttf')
.use(
Fontmin.glyph({
text: titleText,
hinting: false
})
)
.dest('public');
// export function minfont(titleText: string) {
// const fontmin = new Fontmin()
// .src('src/font/SmileySans.ttf')
// .use(
// Fontmin.glyph({
// text: titleText,
// hinting: false
// })
// )
// .dest('public');

fontmin.run((err, files) => {
if (err) throw err;
console.log('compress font success\n');
});
}
// fontmin.run((err, files) => {
// if (err) throw err;
// console.log('compress font success\n');
// });
// }
3 changes: 0 additions & 3 deletions src/utils/minfont.js

This file was deleted.

Loading

0 comments on commit 305079b

Please sign in to comment.