สรรหา

This commit is contained in:
setthawutttty 2024-11-19 13:29:14 +07:00
parent b7a72445bc
commit f2ff047c38
137 changed files with 778 additions and 757 deletions

View file

@ -34,6 +34,7 @@ const parsed = ref<Token[]>([]);
const chapter = ref(0);
const found = ref(false);
const active = ref("");
const subChapter = ref<string>("");
function onScroll() {
let current = "";
@ -66,6 +67,26 @@ async function scrollTo(id: string) {
});
}
// onMounted(async () => {
// window.addEventListener("scroll", onScroll);
// window.addEventListener("resize", onResize);
// if (typeof route.params.name === "string") {
// const res = await fetch(`/documents/${route.params.name}.md`);
// if (res && res.ok) {
// const pattern = /chapter-(\d+)/;
// const match = pattern.exec(route.params.name);
// if (!match) return;
// text.value = await res.text();
// found.value = true;
// chapter.value = +match[1] - 1 ;
// parsed.value = md.parse(text.value, {});
// }
// }
// });
onMounted(async () => {
window.addEventListener("scroll", onScroll);
window.addEventListener("resize", onResize);
@ -73,14 +94,19 @@ onMounted(async () => {
if (typeof route.params.name === "string") {
const res = await fetch(`/documents/${route.params.name}.md`);
if (res && res.ok) {
const pattern = /chapter-(\d+)/;
const pattern = /chapter-(\d+)(?:-(\d+))?/;
const match = pattern.exec(route.params.name);
console.log("🚀 ~ onMounted ~ match:", match)
if (!match) return;
text.value = await res.text();
found.value = true;
chapter.value = +match[1] - 1 ;
const mainChapter = +match[1] - 1;
subChapter.value = match[2] ? `.${match[2]}`:' ';
chapter.value = mainChapter;
parsed.value = md.parse(text.value, {});
}
}
@ -168,6 +194,7 @@ onUnmounted(() => {
color: red;
}
.markdown {
--sub-chapter: v-bind(subChapter);
counter-set: h1 v-bind(chapter);
counter-reset: h1;
}
@ -190,7 +217,7 @@ onUnmounted(() => {
.markdown :deep(h1:before) {
counter-increment: h1;
content: counter(h1) ". ";
content: counter(h1) ". " ;
}
.markdown :deep(h2:before) {

View file

@ -11,7 +11,23 @@ const manual = data.filter((v: any) => v.children);
const mergeManual: any[] = [];
manual.forEach((v: any) => mergeManual.push(...v.children));
manual.forEach((v: any) => {
if (v.children) {
v.children.forEach((i: any) => {
if (i.children) {
i.children.forEach((item: any) => {
if (item.children) {
mergeManual.push(...item.children);
} else {
mergeManual.push(item);
}
});
} else {
mergeManual.push(i);
}
});
}
});
const manualRoute = mergeManual.map(
(v): { path: string; name: string; component: Function } => {