Skip to content

Commit 407f113

Browse files
authored
Swap NodeJs for deno v2 (#42)
* swap nodejs for deno v2 * trigger github pages * fix src/routes/+error.svelte:6:16 `$page` is an illegal variable name. To reference a global variable called `$page`, use `globalThis.$page` https://svelte.dev/e/global_reference_invalid * migrate global state to Svelte 5 runes * site/tsconfig.json "extends": "./.svelte-kit/tsconfig.json" * Fix GitHub Pages workflow to use correct build output directory * track reusable GitHub Pages with Deno workflow and remove lint/formatting dev dependencies * clean up Deno + pre-commit configs * Expand Deno lint rules configuration
1 parent 7fe2734 commit 407f113

20 files changed

+138
-186
lines changed

.github/workflows/gh-pages.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ name: GitHub Pages
33
on:
44
push:
55
branches: [main]
6+
pull_request:
7+
branches: [main]
68
workflow_dispatch:
79

810
jobs:
911
build:
10-
uses: janosh/workflows/.github/workflows/nodejs-gh-pages.yml@main
12+
uses: janosh/workflows/.github/workflows/deno-gh-pages.yml@main
1113
with:
1214
working-directory: site

.github/workflows/link-check.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: Link check
33
on:
44
push:
55
branches: [main]
6-
paths: ["**/*.md"]
6+
paths: ['**/*.md']
77
schedule:
8-
- cron: "0 0 1 * *" # monthly
8+
- cron: '0 0 1 * *' # monthly
99

1010
jobs:
1111
markdown-link-check:

.pre-commit-config.yaml

+17-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ci:
22
autoupdate_schedule: quarterly
3-
skip: [eslint, validate-typst]
3+
skip: [validate-typst, deno-fmt, deno-lint]
44

55
default_install_hook_types: [pre-commit, commit-msg]
66

@@ -17,24 +17,29 @@ repos:
1717
- id: mixed-line-ending
1818
- id: trailing-whitespace
1919

20-
- repo: https://github.com/pre-commit/mirrors-prettier
21-
rev: v4.0.0-alpha.8
20+
- repo: local
2221
hooks:
23-
- id: prettier
24-
stages: [pre-commit]
25-
args: [--write] # edit files in-place
26-
additional_dependencies:
27-
- prettier
28-
- prettier-plugin-svelte
29-
- svelte
22+
- id: deno-fmt
23+
name: Deno format
24+
entry: deno fmt
25+
types: [file]
26+
language: system
27+
args: [--config, site/deno.json]
28+
exclude_types: [markdown]
29+
- id: deno-lint
30+
name: Deno lint
31+
entry: deno lint
32+
args: [--config, site/deno.json]
33+
types: [svelte, javascript, ts]
34+
language: system
3035

3136
- repo: https://github.com/codespell-project/codespell
3237
rev: v2.4.1
3338
hooks:
3439
- id: codespell
3540
stages: [pre-commit, commit-msg]
3641
exclude_types: [svg]
37-
args: [--ignore-words-list, "noe,ket,ba,te,nd", --check-filenames]
42+
args: [--ignore-words-list, 'noe,ket,ba,te,nd', --check-filenames]
3843

3944
- repo: https://github.com/igorshubovych/markdownlint-cli
4045
rev: v0.44.0
@@ -43,23 +48,7 @@ repos:
4348
# MD013: line too long
4449
# MD033: no inline HTML
4550
# MD041: first line in a file should be a top-level heading
46-
args: [--disable, MD013, MD033, MD041, "--"]
47-
48-
- repo: https://github.com/pre-commit/mirrors-eslint
49-
rev: v9.21.0
50-
hooks:
51-
- id: eslint
52-
types: [file]
53-
args: [--fix, --config, site/eslint.config.js]
54-
files: \.(js|ts|svelte)$
55-
additional_dependencies:
56-
- eslint
57-
- svelte
58-
- typescript
59-
- eslint-plugin-svelte
60-
- typescript-eslint
61-
- svelte-eslint-parser
62-
- "@stylistic/eslint-plugin"
51+
args: [--disable, MD013, MD033, MD041, '--']
6352

6453
- repo: local
6554
hooks:

site/.prettierrc.yml

-6
This file was deleted.

site/deno.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"tasks": {
3+
"dev": "deno run -A --node-modules-dir npm:vite dev",
4+
"build": "deno run -A --node-modules-dir npm:vite build",
5+
"preview": "deno run -A --node-modules-dir npm:vite preview",
6+
"lint": "deno lint",
7+
"fmt": "deno fmt"
8+
},
9+
"lock": false,
10+
"lint": {
11+
"rules": {
12+
"tags": ["recommended"],
13+
"include": [
14+
"ban-unused-ignore",
15+
"default-param-last",
16+
"eqeqeq",
17+
"guard-for-in",
18+
"no-await-in-loop",
19+
"no-boolean-literal-for-arguments",
20+
"no-const-assign",
21+
"no-eval",
22+
"no-inferrable-types",
23+
"no-non-null-asserted-optional-chain",
24+
"no-non-null-assertion",
25+
"no-self-compare",
26+
"no-sparse-arrays",
27+
"no-sync-fn-in-async-fn",
28+
"no-throw-literal",
29+
"no-useless-rename",
30+
"prefer-ascii"
31+
]
32+
}
33+
},
34+
"fmt": {
35+
"indentWidth": 2,
36+
"lineWidth": 90,
37+
"semiColons": false,
38+
"singleQuote": true
39+
},
40+
"unstable": ["fmt-component"]
41+
}

site/eslint.config.js

-34
This file was deleted.

site/package.json

+1-15
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,21 @@
33
"description": "Gallery of scientific diagrams along with their Typst and/or LaTeX source code",
44
"homepage": "https://janosh.github.io/diagrams",
55
"license": "MIT",
6-
"name": "tikz",
6+
"name": "scientific-diagrams",
77
"repository": "https://github.com/janosh/diagrams",
88
"type": "module",
99
"version": "1.0.0",
1010
"bugs": "https://github.com/janosh/diagrams/issues",
11-
"scripts": {
12-
"build": "vite build",
13-
"dev": "vite dev",
14-
"preview": "vite preview",
15-
"serve": "vite build && vite preview",
16-
"check": "svelte-check"
17-
},
1811
"devDependencies": {
1912
"@iconify/svelte": "^4.2.0",
2013
"@rollup/plugin-yaml": "^4.1.2",
21-
"@stylistic/eslint-plugin": "^4.0.1",
2214
"@sveltejs/adapter-static": "^3.0.8",
2315
"@sveltejs/enhanced-img": "^0.4.4",
2416
"@sveltejs/kit": "^2.17.2",
2517
"@sveltejs/vite-plugin-svelte": "^5.0.3",
2618
"@types/js-yaml": "^4.0.9",
27-
"eslint": "^9.21.0",
28-
"eslint-plugin-svelte": "^2.46.1",
2919
"highlight.js": "^11.11.1",
3020
"js-yaml": "^4.1.0",
31-
"prettier": "^3.5.2",
32-
"prettier-plugin-svelte": "^3.3.3",
3321
"rehype-katex": "^7.0.1",
3422
"rehype-stringify": "^10.0.1",
3523
"remark-math": "6.0.0",
@@ -41,8 +29,6 @@
4129
"svelte-preprocess": "^6.0.3",
4230
"svelte-zoo": "^0.4.17",
4331
"svelte2tsx": "^0.7.34",
44-
"typescript": "5.7.3",
45-
"typescript-eslint": "^8.24.1",
4632
"unified": "^11.0.5",
4733
"vite": "^6.1.1"
4834
}

site/src/app.css

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ a:hover {
3131
outline: none;
3232
padding: 3pt 1ex;
3333
border-radius: 3pt;
34-
transition:
35-
transform 0.2s,
36-
background-color 0.2s;
34+
transition: transform 0.2s, background-color 0.2s;
3735
cursor: pointer;
3836
}
3937
button:hover {

site/src/app.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33
<head>
44
<meta name="viewport" content="width=device-width, initial-scale=1" />

site/src/lib/Card.svelte

+1-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@
5858
margin: 0;
5959
visibility: hidden;
6060
opacity: 0;
61-
transition:
62-
opacity 0.4s,
63-
visibility 0.4s;
61+
transition: opacity 0.4s, visibility 0.4s;
6462
overflow-wrap: break-word;
6563
width: 100%;
6664
box-sizing: border-box;

site/src/lib/CodeBlock.svelte

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@
2424
<div>
2525
{#if title}
2626
<h3>
27-
{title}
28-
<small>({code.split(`\n`).length} lines)</small>
27+
{title} <small>({code.split(`\n`).length} lines)</small>
2928
</h3>
3029
{/if}
3130
<aside>
3231
{#if github_link}
3332
{@const [link_title, href] = (github_link ?? ``).split(`||`, 2)}
3433
<a {href}>
3534
<button>
36-
<Icon icon="octicon:mark-github" inline />
37-
{link_title}
35+
<Icon icon="octicon:mark-github" inline /> {link_title}
3836
</button>
3937
</a>
4038
{/if}

site/src/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ export const diagrams = Object.entries(yaml_data)
9999
}
100100

101101
return { ...metadata, slug, code, downloads, images }
102-
})
102+
}) as Diagram[]

site/src/lib/state.svelte.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { diagrams } from '$lib'
2+
3+
export const filters = $state<{
4+
search: string
5+
tag_mode: `or` | `and`
6+
tags: { label: string; count: number }[]
7+
}>({
8+
search: ``,
9+
tag_mode: `or`,
10+
tags: [],
11+
})
12+
13+
export const filtered_diagrams = () =>
14+
diagrams
15+
.filter((file) => {
16+
const searchTerms = filters.search?.toLowerCase().split(` `)
17+
const matches_search = searchTerms?.every((term) =>
18+
JSON.stringify(file).toLowerCase().includes(term)
19+
)
20+
21+
let matches_tags = true
22+
if (filters.tags.length > 0) {
23+
if (filters.tag_mode === `or`) {
24+
matches_tags = filters.tags.some((tag) => file.tags.includes(tag.label))
25+
} else if (filters.tag_mode === `and`) {
26+
matches_tags = filters.tags.every((tag) => file.tags.includes(tag.label))
27+
}
28+
}
29+
return matches_search && matches_tags
30+
})
31+
.sort((d1, d2) => {
32+
return d1.title.localeCompare(d2.title)
33+
})

site/src/lib/stores.ts

-17
This file was deleted.

site/src/routes/+error.svelte

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<script lang="ts">
2-
import { page } from '$app/stores'
2+
import { page } from '$app/state'
33
import { homepage, name } from '$root/package.json'
44
import Icon from '@iconify/svelte'
55
66
let online: boolean = $state(true)
77
</script>
88

99
<svelte:head>
10-
<title>Error {$page.status} &bull; {name}</title>
10+
<title>Error {page.status} &bull; {name}</title>
1111
</svelte:head>
1212

1313
<svelte:window bind:online />
1414

1515
<div>
16-
<h1>Error {String($page.status).replace(`0`, `😵`)}: {$page.error?.message}</h1>
17-
{#if $page.status >= 500}
16+
<h1>Error {String(page.status).replace(`0`, `😵`)}: {page.error?.message}</h1>
17+
{#if page.status >= 500}
1818
<p>
1919
If page reloading doesn't help, please raise an issue on
2020
<a href="{homepage}/issues" target="_blank" rel="noreferrer">GitHub</a>. Thanks! 🙏

site/src/routes/+layout.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
{@render children?.()}
3131

32-
<footer style="margin: 6em 0 3em;">
32+
<footer style="margin: 6em 0 3em">
3333
&copy; Janosh Riebesell 2021 &ensp;-&ensp;
3434
<Icon icon="octicon:law" inline />
3535
<a href="{repository}/blob/main/license">MIT License</a>

0 commit comments

Comments
 (0)