Portage du site sous vuejs #232
6 changed files with 60 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
|||
{
|
||||
"name":"Règles de bases"
|
||||
"name":"Règles de bases",
|
||||
"vars":[
|
||||
{"name":"determination01","value":"Effet dépendant du JDR"},
|
||||
{"name":"determination19","value":"Effet dépendant du JDR"},
|
||||
{"name":"determination20","value":"Effet dépendant du JDR"}
|
||||
]
|
||||
}
|
|
@ -19,5 +19,10 @@
|
|||
],
|
||||
"hideLinks":[
|
||||
{ "menu":10, "link":"rules/personnages/niveaux" }
|
||||
],
|
||||
"vars":[
|
||||
{"name":"determination01","value":"Le personnage fait un jet d'apothéose (D100). Si réussite critique: apothéose, si échec critique, jet d'anomie, sinon +1 karma"},
|
||||
{"name":"determination19","value":"Le personnage fait un jet d'anomie"},
|
||||
{"name":"determination20","value":"Le personnage devient anomique"}
|
||||
]
|
||||
}
|
|
@ -149,7 +149,7 @@ Le jet de détermination se fait sur un D20.
|
|||
|
||||
| Résultat | Effet |
|
||||
|:--------:|:------|
|
||||
| 01 | Effet dépendant du JDR |
|
||||
| 01 | {{determination01}} |
|
||||
| 02 | Le personnage gagne un point de karma |
|
||||
| 03-06 | Le personnage fait un jet de bénédiction. |
|
||||
| 07 | Le personnage reçoit la grâce de la royauté. |
|
||||
|
@ -163,7 +163,7 @@ Le jet de détermination se fait sur un D20.
|
|||
| 15 | Les attaques de moral feront 1.5× plus d'effet |
|
||||
| 16-17 | Le personnage fait un jet de pestilence (si PV > PM) ou de panique (si PV < PM). |
|
||||
| 18 | Le personnage à un malus de deux éclat pour la partie.
|
||||
| 19 | Effet dépendant du JDR |
|
||||
| 20 | Effet dépendant du JDR |
|
||||
| 19 | {{determination19}} |
|
||||
| 20 | {{determination20}} |
|
||||
|
||||
</div>
|
||||
|
|
|
@ -5,6 +5,7 @@ import { useTocStore } from "../stores/toc";
|
|||
|
||||
import axios from "axios";
|
||||
import { useRoute } from "vue-router";
|
||||
import { useConfigStore } from "@/stores/config";
|
||||
|
||||
const props = defineProps<{
|
||||
path: string;
|
||||
|
@ -23,6 +24,7 @@ specialQuote.set("DANGER", { class: "danger", text: "Danger :" });
|
|||
var renderer = new marked.Renderer();
|
||||
|
||||
const toc = useTocStore();
|
||||
const config = useConfigStore();
|
||||
const route = useRoute();
|
||||
var tocNbr = 1;
|
||||
|
||||
|
@ -40,7 +42,6 @@ renderer.heading = function (text, level, raw) {
|
|||
};
|
||||
|
||||
renderer.blockquote = function (quote) {
|
||||
console.log(quote);
|
||||
var bqClass = "";
|
||||
var newQuote = quote;
|
||||
for (const [key, quoteData] of specialQuote) {
|
||||
|
@ -56,9 +57,37 @@ renderer.blockquote = function (quote) {
|
|||
return `<blockquote class="${bqClass}">${newQuote}</blockquote>`;
|
||||
};
|
||||
|
||||
const variable = {
|
||||
name: "variable",
|
||||
level: "inline", // Is this a block-level or inline-level tokenizer?
|
||||
start(src: string) {
|
||||
return src.match(/{{/)?.index;
|
||||
}, // Hint to Marked.js to stop and check for a match
|
||||
tokenizer(
|
||||
src: string
|
||||
): { type: string; raw: string; [index: string]: any } | undefined {
|
||||
const rule = /\{\{([A-Za-z0-9_]+)\}\}/; // Regex for the complete token, anchor to string start
|
||||
const match = rule.exec(src);
|
||||
if (match) {
|
||||
return {
|
||||
// Token to generate
|
||||
type: "variable", // Should match "name" above
|
||||
raw: match[0], // Text to consume from the source
|
||||
["varName"]: match[1],
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token: { type: string; raw: string; [index: string]: any }): string {
|
||||
const varName = token["varName"] as string | null;
|
||||
const value = `${config.getVar(varName ?? "")}`;
|
||||
return value;
|
||||
},
|
||||
};
|
||||
|
||||
marked.setOptions({
|
||||
renderer: renderer,
|
||||
});
|
||||
marked.use({ extensions: [variable] });
|
||||
|
||||
function refresh() {
|
||||
const markdownFileUrl = `/${props.path}.md`;
|
||||
|
@ -72,7 +101,6 @@ function refresh() {
|
|||
.then((response) => {
|
||||
tocNbr = 1;
|
||||
htmlContent.value = marked.parse(response.data);
|
||||
console.log(toc);
|
||||
})
|
||||
.catch(
|
||||
() =>
|
||||
|
@ -83,7 +111,9 @@ function refresh() {
|
|||
}
|
||||
|
||||
onMounted(() => {
|
||||
refresh();
|
||||
setTimeout(() => {
|
||||
refresh();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
onBeforeUpdate(() => {
|
||||
|
|
|
@ -70,6 +70,17 @@ export const useConfigStore = defineStore("config", () => {
|
|||
}
|
||||
}
|
||||
|
||||
function getVar(name?: string): string {
|
||||
if (name) {
|
||||
for (const varData of jdrConfig?.value?.vars ?? []) {
|
||||
if (varData.name === name) {
|
||||
return varData.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
return {
|
||||
config,
|
||||
currentJdr,
|
||||
|
@ -79,5 +90,6 @@ export const useConfigStore = defineStore("config", () => {
|
|||
loadJdr,
|
||||
resetJdr,
|
||||
isJdrLoaded,
|
||||
getVar,
|
||||
};
|
||||
});
|
||||
|
|
|
@ -5,4 +5,5 @@ export default interface JdrConfig {
|
|||
name: string;
|
||||
sidebar: LinkList[];
|
||||
hideLinks: HideLink[];
|
||||
vars: { name: string; value: string }[];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue