Skip to content

Commit

Permalink
syntax highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
khanzadimahdi committed May 20, 2024
1 parent 42f518d commit 2986c43
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 14 deletions.
19 changes: 19 additions & 0 deletions frontend/assets/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// Import variables
@import 'variables/index';

// Syntax highlight
@import '~/node_modules/highlight.js/scss/vs.scss';

// Import fonts
@import '~/node_modules/@fortawesome/fontawesome-free/css/all.min.css';

Expand Down Expand Up @@ -44,6 +47,22 @@ body {
padding: 0;
}

pre {
code {
line-height: 1.2rem;

&.hljs {
border: solid 2px #EEE;
border-radius: 1px;
}
}
}

code {
display: inline-block;
direction: ltr;
}

// support rtl
[dir="rtl"] {
body {
Expand Down
9 changes: 6 additions & 3 deletions frontend/components/rich-editor.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,24 @@ const config = {
codeBlock: {
languages: [
{ language: 'plaintext', label: 'Plain text' },
{ language: 'go', label: 'Golang' },
{ language: 'bash', label: '‌Bash' },
{ language: 'c', label: 'C' },
{ language: 'cs', label: 'C#' },
{ language: 'cpp', label: 'C++' },
{ language: 'css', label: 'CSS' },
{ language: 'diff', label: 'Diff' },
{ language: 'go', label: 'Golang' },
{ language: 'html', label: 'HTML' },
{ language: 'java', label: 'Java' },
{ language: 'javascript', label: 'JavaScript' },
{ language: 'json', label: 'JSON' },
{ language: 'makefile', label: 'Makefile' },
{ language: 'php', label: 'PHP' },
{ language: 'python', label: 'Python' },
{ language: 'ruby', label: 'Ruby' },
{ language: 'typescript', label: 'TypeScript' },
{ language: 'json', label: 'JSON' },
{ language: 'xml', label: 'XML' }
{ language: 'xml', label: 'XML' },
{ language: 'yaml', label: 'YAML' }
]
}
}
Expand Down
9 changes: 9 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@vueform/multiselect": "^2.6.6",
"bootstrap": "^5.3.2",
"defu": "^6.1.4",
"highlight.js": "^11.9.0",
"jwt-decode": "^4.0.0",
"medium-zoom": "^1.1.0",
"sass": "^1.75.0",
Expand Down
26 changes: 15 additions & 11 deletions frontend/pages/articles/[uuid].vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,23 @@
</template>

<script setup>
const {uuid} = useRoute().params;
import hljs from 'highlight.js'
const resolveFileUrl = useFilesUrlResolver().resolve
const {uuid} = useRoute().params;
const data = await $fetch(useApiUrlResolver().resolve(`api/articles/${uuid}`))
const resolveFileUrl = useFilesUrlResolver().resolve
useHead({
title: data.title,
meta: [
{ name: 'description', content: data.excerpt },
],
link: [
{ rel: 'canonical', href: `/articles/${uuid}` }
]
const data = await $fetch(useApiUrlResolver().resolve(`api/articles/${uuid}`))
useHead({
title: data.title,
meta: [
{ name: 'description', content: data.excerpt },
],
link: [
{ rel: 'canonical', href: `/articles/${uuid}` }
]
})
onMounted(hljs.highlightAll)
</script>

0 comments on commit 2986c43

Please sign in to comment.