Skip to content

Commit

Permalink
v0.3.110
Browse files Browse the repository at this point in the history
  • Loading branch information
CarcajadaArtificial committed Sep 21, 2024
1 parent c0a80d3 commit ee2d01e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.3.110

- Added plugin fix that points to jsDelivr github cdn.

## v0.3.109

- Updated the README.
Expand Down
53 changes: 23 additions & 30 deletions plugin.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,42 @@
import { Plugin } from '$fresh/server.ts';
import { ResinCssEmitter } from './deps.ts';
import { ensureDir, walk } from 'https://deno.land/[email protected]/fs/mod.ts';
import { join } from 'https://deno.land/[email protected]/path/mod.ts';

async function copyFilesRecursively(from: string, to: string): Promise<void> {
await ensureDir(to);

for await (const entry of walk(from, { includeDirs: true })) {
const relativePath = entry.path.substring(from.length);
const targetPath = join(to, relativePath);

if (entry.isDirectory) {
await ensureDir(targetPath);
} else if (entry.isFile) {
await Deno.copyFile(entry.path, targetPath);
}
}
}

const styles = await Deno.readTextFile(
new URL('./static/styles.css', import.meta.url).pathname,
);
// import { ensureDir, walk } from 'https://deno.land/[email protected]/fs/mod.ts';
// import { join } from 'https://deno.land/[email protected]/path/mod.ts';

export default function lunchboxPlugin(): Plugin {
return {
name: 'lunchbox',
buildStart: (ctx) =>
copyFilesRecursively(
new URL('./static/fonts/', import.meta.url).pathname,
ctx.staticDir + '/fonts/',
),
render: (ctx) => {
ctx.render();

return {
styles: [
{
id: 'lunchbox-css-reset',
cssText: styles,
},
{
id: 'resin-css-page-css-tag',
cssText: ResinCssEmitter({})!.props.children,
},
],
head: [
// Link to your main CSS file
`<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/styles.css">`,

// Preload Figtree fonts
`<link rel="preload" href="https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/Figtree/Figtree-700.woff2" as="font" type="font/woff2" crossorigin="anonymous">`,
`<link rel="preload" href="https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/Figtree/Figtree-Italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">`,
`<link rel="preload" href="https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/Figtree/Figtree-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">`,

// Preload FiraCode fonts
`<link rel="preload" href="https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/FiraCode/FiraCode-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">`,
`<link rel="preload" href="https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/FiraCode/FiraCode-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">`,

// Preload Libre Caslon Text fonts
`<link rel="preload" href="https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/LibreCaslonText/Libre-Caslon-Text-700.woff2" as="font" type="font/woff2" crossorigin="anonymous">`,
`<link rel="preload" href="https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/LibreCaslonText/Libre-Caslon-Text-Italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">`,
`<link rel="preload" href="https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/LibreCaslonText/Libre-Caslon-Text-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">`,

// Load fonts.css for any additional font-related styles
`<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/fonts.css">`,
],
};
},
};
Expand Down
16 changes: 8 additions & 8 deletions static/fonts/fonts.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,61 @@
font-weight: 400;
font-style: normal;
font-display: swap;
src: url('./FiraCode/FiraCode-Regular.woff2') format('woff2');
src: url('https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/FiraCode/FiraCode-Regular.woff2') format('woff2');
}

@font-face {
font-family: 'Fira Code';
font-weight: 700;
font-style: normal;
font-display: swap;
src: url('./FiraCode/FiraCode-Bold.woff2') format('woff2');
src: url('https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/FiraCode/FiraCode-Bold.woff2') format('woff2');
}

@font-face {
font-family: 'Figtree';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url('./Figtree/Figtree-Regular.woff2') format('woff2');
src: url('https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/Figtree/Figtree-Regular.woff2') format('woff2');
}

@font-face {
font-family: 'Figtree';
font-style: italic;
font-weight: 400;
font-display: swap;
src: url('./Figtree/Figtree-Italic.woff2') format('woff2');
src: url('https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/Figtree/Figtree-Italic.woff2') format('woff2');
}

@font-face {
font-family: 'Figtree';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url('./Figtree/Figtree-700.woff2') format('woff2');
src: url('https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/Figtree/Figtree-700.woff2') format('woff2');
}

@font-face {
font-family: 'Libre Caslon Text';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url('./LibreCaslonText/Libre-Caslon-Text-Regular.woff2') format('woff2');
src: url('https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/LibreCaslonText/Libre-Caslon-Text-Regular.woff2') format('woff2');
}

@font-face {
font-family: 'Libre Caslon Text';
font-style: italic;
font-weight: 400;
font-display: swap;
src: url('./LibreCaslonText/Libre-Caslon-Text-Italic.woff2') format('woff2');
src: url('https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/LibreCaslonText/Libre-Caslon-Text-Italic.woff2') format('woff2');
}

@font-face {
font-family: 'Libre Caslon Text';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url('./LibreCaslonText/Libre-Caslon-Text-700.woff2') format('woff2');
src: url('https://cdn.jsdelivr.net/gh/CarcajadaArtificial/lunchbox/static/fonts/LibreCaslonText/Libre-Caslon-Text-700.woff2') format('woff2');
}

0 comments on commit ee2d01e

Please sign in to comment.