Skip to content

Commit

Permalink
integrate comment with component, try css transmit
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuka007 committed Sep 26, 2024
1 parent 6aae690 commit 86913bb
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 34 deletions.
15 changes: 7 additions & 8 deletions src/.vuepress/client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// import { defineClientConfig, useRoute } from 'vuepress/client'
// import { onMounted } from 'vue'
import { defineClientConfig } from 'vuepress/client'
import DiscourseComments from './component/DiscourseComments.vue'

// export default defineClientConfig({
// setup() {
// // useRoute().path
// window.location.href
// }
// })
export default defineClientConfig({
enhance({ app }) {
app.component('DiscourseComments', DiscourseComments)
},
})

declare global {
interface Window {
Expand Down
22 changes: 22 additions & 0 deletions src/.vuepress/component/DiscourseComments.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<div id="discourse-comments"></div>
</template>

<script setup>
import { onMounted } from 'vue'
import { useRoute } from 'vuepress/client'
onMounted(() => {
window.DiscourseEmbed = {
discourseUrl: 'https://bbs.scutosc.cn/',
discourseEmbedUrl: window.location.origin + useRoute().path.split('#')[0],
className: 'vp-bg',
};
(function() {
var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
d.src = window.DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
})();
})
</script>
4 changes: 3 additions & 1 deletion src/guide/student/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ title: GitHub (Copilot)
icon: "mdi:github"
---

TODO: 介绍 GitHub 学生优惠。
TODO: 介绍 GitHub 学生优惠。

<DiscourseComments />
4 changes: 3 additions & 1 deletion src/guide/student/matlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ icon: vscode-icons:file-type-matlab

::: tip
点此进入 [MatLab正版化文档](https://web.scut.edu.cn/2023/0316/c31531a494035/page.htm)
:::
:::

<DiscourseComments />
2 changes: 2 additions & 0 deletions src/guide/student/ms-office.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ SCUT学生可以 **下载学校提供的微软正版软件**,并 **通过学
#### MacOS

[Microsoft_Office_16.59.22031300_Installer.pkg](https://mswebdl.scut.edu.cn/download/office/Microsoft_Office_16.59.22031300_Installer.pkg)

<DiscourseComments />
4 changes: 3 additions & 1 deletion src/guide/tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ title: Tools
icon: mdi:toolbox
---

<Catalog />
<Catalog />

<DiscourseComments />
2 changes: 2 additions & 0 deletions src/guide/tools/code-share.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ author: { name: Samuka007, url: https://github.com/Samuka007 }
[Code Explorer](https://compiler-explorer.com) from [godbolt](https://godbolt.org),是一个在线编译器,可以将 C/C++ 代码转换为汇编代码,查看结果,支持多种编译器、优化等设置,还能生成链接分享。

![compiler-explorer.com](https://github.com/compiler-explorer/compiler-explorer/raw/main/docs/images/brief_overview.png)

<DiscourseComments />
4 changes: 3 additions & 1 deletion src/guide/tools/vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ title: Visual Studio Code
icon: "fa-solid fa-code"
---

<Catalog />
<Catalog />

<DiscourseComments />
4 changes: 3 additions & 1 deletion src/guide/tools/vscode/install_vscode_on_windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ summary: Install Visual Studio Code on Windows
同时,也会提示你是否将VS Code添加到右键菜单中。这里推荐你选择添加,这样你可以在文件夹中直接右键打开VS Code。
<!-- link to using_vscode -->

[WinGet]: https://learn.microsoft.com/en-us/windows/package-manager/winget/
[WinGet]: https://learn.microsoft.com/en-us/windows/package-manager/winget/

<DiscourseComments />
4 changes: 3 additions & 1 deletion src/guide/tools/vscode/using_vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ draft: false
## 工作区 Workspace

> - [Workspaces in Visual Studio Code](https://code.visualstudio.com/docs/editor/workspaces)
> - 中文:[Visual Studio Code 中的工作区](https://vscode.github.net.cn/docs/editor/workspaces)
> - 中文:[Visual Studio Code 中的工作区](https://vscode.github.net.cn/docs/editor/workspaces)
<DiscourseComments />
2 changes: 2 additions & 0 deletions src/guide/tools/vscode/vscode_cpp_common.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,5 @@ $ xmake project -k compile_commands .vscode
```

如果配置后,还是没生效,可以尝试重启 vscode 和 clangd 进程,再验证下。

<DiscourseComments />
21 changes: 1 addition & 20 deletions src/guide/windows_cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,4 @@ $ code test
## 配置Clangd
TODO

<div id='discourse-comments'></div>

<script setup>
import { onMounted } from 'vue'
import { useRoute } from 'vuepress/client'

onMounted(() => {
window.DiscourseEmbed = {
discourseUrl: 'https://bbs.scutosc.cn/',
discourseEmbedUrl: window.location.origin + useRoute().path.split('#')[0],
// className: 'CLASS_NAME',
};

(function() {
var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
d.src = window.DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
})();
})
</script>
<DiscourseComments />

0 comments on commit 86913bb

Please sign in to comment.