Skip to content

Commit b6b02bd

Browse files
committed
compress
1 parent d3e8791 commit b6b02bd

File tree

12 files changed

+1470
-338
lines changed

12 files changed

+1470
-338
lines changed

.github/workflows/deploy.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ jobs:
6868
echo "✅ Using cached embeddings and blog context"
6969
mkdir -p dist/static/data dist/static/js
7070
71+
- name: Cache transformer models
72+
uses: actions/cache@v4
73+
with:
74+
path: ~/.cache/huggingface
75+
key: transformers-${{ hashFiles('**/package-lock.json') }}
76+
restore-keys: |
77+
transformers-
78+
7179
- name: Build site
7280
run: npm run build
7381
env:

astro.config.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from 'astro/config';
22
import sitemap from '@astrojs/sitemap';
33
import embeddingsIntegration from './integrations/embeddings.js';
4+
import compress from 'astro-compress';
45

56
// https://astro.build/config
67
export default defineConfig({
@@ -56,7 +57,17 @@ export default defineConfig({
5657
include: ['es-toolkit']
5758
}
5859
},
59-
integrations: [sitemap(), embeddingsIntegration()],
60+
integrations: [
61+
sitemap(),
62+
embeddingsIntegration(),
63+
compress({
64+
CSS: true,
65+
HTML: true,
66+
Image: false,
67+
JavaScript: true,
68+
SVG: true
69+
})
70+
],
6071
markdown: {
6172
shikiConfig: {
6273
theme: 'github-dark',

package-lock.json

Lines changed: 1306 additions & 197 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
"type": "module",
66
"scripts": {
77
"dev": "astro dev",
8-
"build": "astro check && astro build",
8+
"build": "astro build",
99
"build:local": "astro check && astro build && npm run pdf",
1010
"preview": "astro preview",
1111
"check": "astro check",
1212
"clean": "rm -rf dist",
1313
"np": "node scripts/new-post.js",
1414
"rotate": "node scripts/rotate-image.js",
15-
"pdf": "node scripts/generate-pdf.js"
15+
"pdf": "node scripts/generate-pdf.js",
16+
"analyze": "ANALYZE=true astro build"
1617
},
1718
"devDependencies": {
1819
"@astrojs/check": "^0.9.4",
1920
"astro": "^5.11.0",
21+
"astro-compress": "^2.3.8",
2022
"sharp": "^0.34.3",
2123
"typescript": "^5.8.3"
2224
},

public/static/css/ama.css

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,102 @@ main {
400400
display: none;
401401
}
402402
}
403+
404+
/* Highlight.js styles for AMA code blocks */
405+
.response-area pre {
406+
background: #24292e !important;
407+
border-radius: 6px;
408+
padding: 1em !important;
409+
overflow-x: auto;
410+
}
411+
412+
.response-area pre code.hljs {
413+
background: transparent !important;
414+
color: #e1e4e8 !important;
415+
padding: 0 !important;
416+
}
417+
418+
/* Copy highlight.js color scheme from common.css */
419+
.response-area .hljs-comment,
420+
.response-area .hljs-quote {
421+
color: #6a737d;
422+
font-style: italic;
423+
}
424+
425+
.response-area .hljs-keyword,
426+
.response-area .hljs-selector-tag,
427+
.response-area .hljs-type,
428+
.response-area .hljs-built_in {
429+
color: #f97583;
430+
}
431+
432+
.response-area .hljs-string,
433+
.response-area .hljs-doctag,
434+
.response-area .hljs-char {
435+
color: #9ecbff;
436+
}
437+
438+
.response-area .hljs-function,
439+
.response-area .hljs-title,
440+
.response-area .hljs-section,
441+
.response-area .hljs-title.function_,
442+
.response-area .hljs-title.class_ {
443+
color: #b392f0;
444+
}
445+
446+
.response-area .hljs-variable,
447+
.response-area .hljs-attribute,
448+
.response-area .hljs-property,
449+
.response-area .hljs-attr {
450+
color: #79b8ff;
451+
}
452+
453+
.response-area .hljs-number,
454+
.response-area .hljs-literal,
455+
.response-area .hljs-boolean {
456+
color: #79b8ff;
457+
}
458+
459+
.response-area .hljs-regexp,
460+
.response-area .hljs-link {
461+
color: #dbedff;
462+
}
463+
464+
.response-area .hljs-symbol,
465+
.response-area .hljs-constant {
466+
color: #79b8ff;
467+
}
468+
469+
.response-area .hljs-tag,
470+
.response-area .hljs-meta,
471+
.response-area .hljs-meta-keyword {
472+
color: #ea4a5a;
473+
}
474+
475+
.response-area .hljs-operator,
476+
.response-area .hljs-punctuation {
477+
color: #e1e4e8;
478+
}
479+
480+
.response-area .hljs-template-variable,
481+
.response-area .hljs-template-tag {
482+
color: #c8e1ff;
483+
}
484+
485+
.response-area .hljs-emphasis {
486+
font-style: italic;
487+
}
488+
489+
.response-area .hljs-strong {
490+
font-weight: bold;
491+
}
492+
493+
.response-area .hljs-deletion {
494+
color: #fdaeb7;
495+
background-color: #86181d;
496+
}
497+
498+
.response-area .hljs-addition {
499+
color: #bef5cb;
500+
background-color: #22863a;
501+
}

public/static/css/post.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
background-color: var(--color-bg-secondary);
5151
}
5252

53-
.post-tags {
53+
.post-content .post-tags {
5454
display: flex;
5555
flex-wrap: wrap;
5656
gap: 0.5rem;
@@ -152,7 +152,7 @@
152152
font-size: 2rem;
153153
}
154154

155-
.post-tags {
155+
.post-content .post-tags {
156156
justify-content: flex-start;
157157
}
158158
}

public/static/css/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ footer {
799799
display: flex;
800800
gap: 0.5rem;
801801
flex-wrap: wrap;
802+
justify-content: center;
802803
}
803804

804805
.search-results {

public/static/js/ama.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,29 @@ import _ from './utils/native-utils.js';
252252
function formatResponse(response) {
253253
// Use marked.js with highlight.js for proper markdown rendering
254254
if (typeof marked !== 'undefined' && typeof hljs !== 'undefined') {
255-
// Configure marked with highlight.js
256-
const renderer = new marked.Renderer();
255+
// Configure marked without highlight first
256+
marked.setOptions({
257+
breaks: true,
258+
gfm: true,
259+
headerIds: false,
260+
mangle: false
261+
});
262+
263+
// Render markdown
264+
let html = marked.parse(response);
257265

258-
// Custom code renderer
259-
renderer.code = function(code, language) {
260-
// Ensure code is a string
261-
const codeStr = String(code || '');
266+
// Create a temporary div to manipulate the HTML
267+
const temp = document.createElement('div');
268+
temp.innerHTML = html;
269+
270+
// Find all code blocks and apply highlight.js
271+
temp.querySelectorAll('pre code').forEach((block) => {
272+
// Try to detect language from class
273+
let language = null;
274+
const classMatch = block.className.match(/language-(\w+)/);
275+
if (classMatch) {
276+
language = classMatch[1];
277+
}
262278

263279
// Handle language aliases
264280
const langMap = {
@@ -268,35 +284,23 @@ import _ from './utils/native-utils.js';
268284
'exs': 'elixir'
269285
};
270286

271-
const actualLang = langMap[language] || language;
272-
let highlighted;
287+
if (language && langMap[language]) {
288+
language = langMap[language];
289+
}
273290

274291
try {
275-
if (actualLang && hljs.getLanguage(actualLang)) {
276-
// hljs.highlight expects (language, code) in v11
277-
highlighted = hljs.highlight(actualLang, codeStr).value;
292+
if (language && hljs.getLanguage(language)) {
293+
block.innerHTML = hljs.highlight(language, block.textContent).value;
278294
} else {
279-
highlighted = hljs.highlightAuto(codeStr).value;
295+
block.innerHTML = hljs.highlightAuto(block.textContent).value;
280296
}
297+
block.classList.add('hljs');
281298
} catch (err) {
282299
console.warn('Highlight error:', err);
283-
// Fallback to escaped HTML
284-
highlighted = escapeHtml(codeStr);
285300
}
286-
287-
return `<pre class="hljs" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto; padding: 1em;" tabindex="0"><code class="language-${actualLang || ''}">${highlighted}</code></pre>`;
288-
};
289-
290-
marked.setOptions({
291-
renderer: renderer,
292-
breaks: true,
293-
gfm: true,
294-
headerIds: false,
295-
mangle: false
296301
});
297302

298-
// Render markdown
299-
return marked.parse(response);
303+
return temp.innerHTML;
300304
} else {
301305
// Fallback to simple text if marked is not available
302306
console.warn('Marked or hljs not available, using fallback');

public/static/js/utils.mjs

Lines changed: 0 additions & 28 deletions
This file was deleted.

public/static/resume.pdf

-1 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)