link opening in app
This commit is contained in:
1 parent
279b5886b1
commit
ff98be7d7c
12 files changed
+560
-33
No files matched your search
@@ -1,14 +1,17 @@
|
||||
import "./style.css";
|
||||
import "./custom.css";
|
||||
import "./style.css";
|
||||
|
||||
import DefaultTheme from "vitepress/theme";
|
||||
// https://vitepress.dev/guide/custom-theme
|
||||
import { h } from "vue";
|
||||
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
|
||||
import SentenceQuiz from "./components/SentenceQuiz.vue";
|
||||
import TOC from "./components/TOC.vue";
|
||||
|
||||
import type { Theme } from "vitepress";
|
||||
|
||||
export default {
|
||||
extends: DefaultTheme,
|
||||
Layout: () => {
|
||||
@@ -17,6 +20,24 @@ export default {
|
||||
});
|
||||
},
|
||||
enhanceApp({ app, router, siteData }) {
|
||||
app.runWithContext(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
window.document.addEventListener("click", (ev) => {
|
||||
const { target } = ev;
|
||||
if (!target || !(target instanceof HTMLAnchorElement)) return;
|
||||
if (target.href.startsWith("https://")) {
|
||||
ev.preventDefault();
|
||||
if (
|
||||
target.href.startsWith(
|
||||
"https://resources.allsetlearning.com/chinese/grammar/",
|
||||
)
|
||||
)
|
||||
return;
|
||||
openUrl(target.href);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ...
|
||||
app.component("SentenceQuiz", SentenceQuiz);
|
||||
app.component("TOC", TOC);
|
||||
|
||||
@@ -35,5 +35,4 @@
|
||||
|
||||
- ["Due to…" with "由于"](../../B2/由于.md)
|
||||
- [Stating the Effect before the Cause](../../B2/之所以.md)
|
||||
- [Explaining results with "所以"](https://resources.allsetlearning.com/chinese/grammar/Explaining_results_with_%22suoyi%22)
|
||||
- [Cause and Effect with "因为" and "所以"](https://resources.allsetlearning.com/chinese/grammar/Cause_and_Effect_with_%22yinwei%22_and_%22suoyi%22)
|
||||
- [Cause and Effect with "因为" and "所以"](../../A2/因为...所以.md)
|
||||
@@ -89,7 +89,6 @@ Sometimes, 因为 can be shortened to just 因. This is used more in sentences t
|
||||
## See also
|
||||
|
||||
- [Cause and effect with "因为" and "所以"](../A2/因为...所以.md)
|
||||
- [Explaining results with "所以"](https://resources.allsetlearning.com/chinese/grammar/Explaining_results_with_%22suoyi%22)
|
||||
|
||||
## Sources and further reading
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# zhdiary
|
||||
# zh-grammar
|
||||
|
||||
## Chinese [Grammar Wiki](./allsetlearning/index.md)
|
||||
|
||||
|
||||
Reference in new issue
Block a user