Skip to content

Commit

Permalink
fix: code fence is not highlighted by prism after refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Aug 9, 2023
1 parent 7478780 commit 8b77aa2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/components/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export default defineComponent({
watch(
() => appStore.locale,
(newLocale, oldLocale) => {
console.log(newLocale, oldLocale)
if (waline && newLocale !== undefined && newLocale !== oldLocale) {
waline.update({
lang: languages[newLocale]
Expand Down
14 changes: 9 additions & 5 deletions src/views/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
</template>

<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue'
import { defineComponent, nextTick, onMounted, ref } from 'vue'
import { useArticleStore } from '@/stores/article'
import { Page } from '@/models/Article.class'
import PageContent from '@/components/PageContent.vue'
import Breadcrumbs from '@/components/Breadcrumbs.vue'
import { useI18n } from 'vue-i18n'
declare const Prism: any
export default defineComponent({
name: 'About',
components: { PageContent, Breadcrumbs },
Expand All @@ -21,10 +23,12 @@ export default defineComponent({
const pageData = ref(new Page())
const { t } = useI18n()
const fetchArticle = () => {
articleStore.fetchArticle('about').then(response => {
pageData.value = response
})
const fetchArticle = async () => {
const response = await articleStore.fetchArticle('about')
pageData.value = response
await nextTick()
Prism.highlightAll()
}
onMounted(fetchArticle)
Expand Down
27 changes: 19 additions & 8 deletions src/views/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
</template>

<script lang="ts">
import { computed, defineComponent, onBeforeMount, ref, watch } from 'vue'
import {
computed,
defineComponent,
nextTick,
onBeforeMount,
ref,
watch
} from 'vue'
import { useArticleStore } from '@/stores/article'
import { Page } from '@/models/Article.class'
import { useI18n } from 'vue-i18n'
Expand All @@ -25,6 +32,8 @@ import PageContent from '@/components/PageContent.vue'
import Breadcrumbs from '@/components/Breadcrumbs.vue'
import Comment from '@/components/Comment.vue'
declare const Prism: any
export default defineComponent({
name: 'Page',
components: { PageContent, Breadcrumbs, Comment },
Expand All @@ -37,14 +46,16 @@ export default defineComponent({
const { t } = useI18n()
const pageTitle = ref()
const fetchArticle = () => {
articleStore.fetchArticle(String(route.params.slug)).then(response => {
pageData.value = response
pageTitle.value = pageData.value.title
const fetchArticle = async () => {
const response = await articleStore.fetchArticle(
String(route.params.slug)
)
updateTitle(appStore.locale)
})
pageData.value = response
pageTitle.value = response.title
updateTitle(appStore.locale)
await nextTick()
Prism.highlightAll()
}
const updateTitle = (locale: string | undefined) => {
Expand Down
2 changes: 0 additions & 2 deletions src/views/Post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ import { useI18n } from 'vue-i18n'
import Comment from '@/components/Comment.vue'
import { SubTitle } from '@/components/Title'
import { Article } from '@/components/ArticleCard'
import '@/styles/prism-aurora-future.css'
import { useMetaStore } from '@/stores/meta'
import { useAppStore } from '@/stores/app'
import { useCommonStore } from '@/stores/common'
Expand Down

0 comments on commit 8b77aa2

Please sign in to comment.