Skip to content

Commit 27f9383

Browse files
committed
schoedinger as default
1 parent c7c85ad commit 27f9383

File tree

1 file changed

+41
-37
lines changed

1 file changed

+41
-37
lines changed

src/components/controls/EquationSelector.vue

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:key="equation.id"
66
:class="{
77
active: equation.id === currentId,
8-
'new-equation': equation.id === 'new'
8+
'new-equation': equation.id === 'new',
99
}"
1010
@click="selectEquation(equation.id)"
1111
>
@@ -15,77 +15,81 @@
1515
</template>
1616

1717
<script setup lang="ts">
18-
import { ref, onMounted } from 'vue'
19-
import { parseContent } from '../../utils/parser'
18+
import { ref, onMounted } from "vue";
19+
import { parseContent } from "../../utils/parser";
2020
2121
interface EquationInfo {
22-
id: string
23-
title: string
24-
content: string
22+
id: string;
23+
title: string;
24+
content: string;
2525
}
2626
2727
const emit = defineEmits<{
28-
change: [markdown: string]
29-
}>()
28+
change: [markdown: string];
29+
}>();
3030
31-
const equations = ref<EquationInfo[]>([])
32-
const currentId = ref('')
31+
const equations = ref<EquationInfo[]>([]);
32+
const currentId = ref("");
3333
3434
// Vite glob import for markdown files
35-
const equationFiles = import.meta.glob('../../examples/*.md', { query: '?raw', import: 'default', eager: true })
35+
const equationFiles = import.meta.glob("../../examples/*.md", {
36+
query: "?raw",
37+
import: "default",
38+
eager: true,
39+
});
3640
3741
async function loadEquations(): Promise<EquationInfo[]> {
38-
const result: EquationInfo[] = []
42+
const result: EquationInfo[] = [];
3943
4044
for (const path in equationFiles) {
41-
const content = equationFiles[path] as string
42-
const filename = path.split('/').pop() || ''
43-
const id = filename.replace('.md', '')
44-
const parsed = parseContent(content)
45+
const content = equationFiles[path] as string;
46+
const filename = path.split("/").pop() || "";
47+
const id = filename.replace(".md", "");
48+
const parsed = parseContent(content);
4549
46-
result.push({ id, title: parsed.title, content })
50+
result.push({ id, title: parsed.title, content });
4751
}
4852
4953
return result.sort((a, b) => {
50-
if (a.id === 'new') return -1
51-
if (b.id === 'new') return 1
52-
return a.title.localeCompare(b.title)
53-
})
54+
if (a.id === "new") return -1;
55+
if (b.id === "new") return 1;
56+
return a.title.localeCompare(b.title);
57+
});
5458
}
5559
5660
function selectEquation(id: string) {
57-
const equation = equations.value.find(eq => eq.id === id)
58-
if (!equation) return
61+
const equation = equations.value.find((eq) => eq.id === id);
62+
if (!equation) return;
5963
60-
currentId.value = id
61-
window.location.hash = id
62-
emit('change', equation.content)
64+
currentId.value = id;
65+
window.location.hash = id;
66+
emit("change", equation.content);
6367
}
6468
6569
function getIdFromHash(): string {
66-
return window.location.hash.slice(1) || ''
70+
return window.location.hash.slice(1) || "";
6771
}
6872
6973
onMounted(async () => {
70-
equations.value = await loadEquations()
74+
equations.value = await loadEquations();
7175
7276
// Get initial equation from URL hash or default
73-
const hashId = getIdFromHash()
74-
const exists = equations.value.some(eq => eq.id === hashId)
75-
const initialId = exists ? hashId : (equations.value[0]?.id ?? '')
77+
const hashId = getIdFromHash();
78+
const exists = equations.value.some((eq) => eq.id === hashId);
79+
const initialId = exists ? hashId : "schrodinger";
7680
7781
if (initialId) {
78-
selectEquation(initialId)
82+
selectEquation(initialId);
7983
}
8084
8185
// Listen for hash changes
82-
window.addEventListener('hashchange', () => {
83-
const newId = getIdFromHash()
86+
window.addEventListener("hashchange", () => {
87+
const newId = getIdFromHash();
8488
if (newId && newId !== currentId.value) {
85-
selectEquation(newId)
89+
selectEquation(newId);
8690
}
87-
})
88-
})
91+
});
92+
});
8993
</script>
9094

9195
<style scoped>

0 commit comments

Comments
 (0)