Skip to content

Commit

Permalink
faq page in vue
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed May 5, 2024
1 parent 40acca5 commit 8e7ea8c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
8 changes: 8 additions & 0 deletions css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2173,4 +2173,12 @@ input[type=radio] {

.col-6 {
width: 49%;
}

.faq-question {
padding-top: 50px;
}

.faq-answer {
padding-left: 20px;
}
10 changes: 10 additions & 0 deletions faq.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
layout: default
title: FAQ
---

<div id="app"></div>

<script defer src="js/axios.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/marked.min.js"></script>
<script defer src="js/faq.js"></script>
40 changes: 40 additions & 0 deletions js/faq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
document.addEventListener("DOMContentLoaded", () => {
const v = new Vue({
el: "#app",
data() {
return {
faqs: [],
}
},
template: `
<div>
<h1 class="display-3 my-5 text-center">Frequently Asked Questions</h1>
<template v-for="(faq, i) in faqs" :key="i">
<template v-if="!faq.discord">
<h2 class="faq-question">{{ faq.question }}</h2>
<p v-html="parseMd(faq.answer)" class="faq-answer"></p>
</template>
</template>
</div>
`,
methods: {
parseMd(text) {
return marked.parse(
text
.replace(/in <#[^]+>/, "on our [Discord](https://discord.gg/sN9YRQbBv7)") // removes channel links
.replace(/<[^]+>/, "") // removes pings
.replace("()", ""), // removes stray parentheses left by removing pings)
)
},
},
created() {
axios
.get(
"https://raw.githubusercontent.com/Faithful-Resource-Pack/CompliBot/main/json/faq.json",
)
.then((res) => {
this.faqs = res.data
})
},
})
})

0 comments on commit 8e7ea8c

Please sign in to comment.