Skip to content
Snippets Groups Projects
Commit 53b3881e authored by Rene Roesner's avatar Rene Roesner
Browse files

Merge branch 'feat/extend-faq-list' into 'main'

planning#320 Erweiterung FAQ

See merge request !160
parents 1f44e39f e2013ca3
No related branches found
No related tags found
1 merge request!160fit-connect/planning#320 Erweiterung FAQ
......@@ -24,3 +24,6 @@ build/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
scripts/faq.md
scripts/faq.json
......@@ -4,11 +4,17 @@ Die Dokumentation ist hier zu finden: https://docs.fitko.de/fit-connect/
## Lokale Entwicklung
### Serves the last build statically made
```shell
$ yarn
$ yarn start
```
### Serves the current active dev environment
```shell
$ yarn
$ yarn serve
```
## Bauen für Produktion
```shell
......
......@@ -7,6 +7,7 @@
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"parse": "node scripts/faqParser",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids"
},
......@@ -35,6 +36,7 @@
"rapidoc": "^9.1.3",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-jsx-parser": "^1.29.0",
"remark-collapse": "^0.1.2",
"sass": "^1.45.0",
"semver": "^7.3.5",
......
const fs = require('fs');
const readline = require('readline');
const faq = {
groups: []
};
const configRemoveEmptyGroups = true;
async function parseFaq() {
const fileStream = fs.createReadStream('scripts/faq.md');
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity
});
let lastGroup = 0;
let lastSubgroup = 0;
let lastItem = 0;
for await (const line of rl) {
//console.log(`Line from file: ${line}`);
if (line.startsWith('# ')) {
const name = line.substring(2);
lastSubgroup = 0;
faq
.groups
.push({ name, anchor: slugify(name), subgroups: [] });
lastGroup = faq.groups.length - 1;
//console.log('group, index, subgroups: ', faq.groups[lastGroup], lastGroup, lastSubgroup);
} else if (line.startsWith('## ')) {
const name = line.substring(3);
lastItem = 0;
faq
.groups[lastGroup]
.subgroups
.push({ name, anchor: slugify(name), items: [] });
lastSubgroup = faq.groups[lastGroup].subgroups.length - 1;
//console.log('subgroup, item: ', lastSubgroup, lastItem);
} else if (line.startsWith('### ')) {
const title = line.substring(4);
// new item
faq
.groups[lastGroup]
.subgroups[lastSubgroup]
.items
.push({ title, content: '' });
lastItem = faq.groups[lastGroup].subgroups[lastSubgroup].items.length - 1;
//console.log('subgroup, item: ', lastSubgroup, lastItem);
} else if (!line.startsWith('[')) {
let newLine = line;
if (newLine.length > 0) {
// look for markdown URLs
const mdRegex = /\[([^\[]+)\]\((.*?)\)/;
const mdUrl = line.match(mdRegex);
if (mdUrl) {
//console.log('mdUrl: ', mdUrl);
newLine = newLine.replace(mdUrl[0],
` <Link to={'${mdUrl[2]}'}>${mdUrl[1]}</Link> `);
} else {
// look for raw URLs
const urlRegex = /(https?:\/\/[^ ]*)/;
const url = newLine.match(urlRegex);
if (url) {
newLine = newLine.replace(url[1],
` <Link to={'${url[1]}'}>${url[1]}</Link> `);
}
}
// everything else is text of the last item
let item = faq.groups[lastGroup].subgroups[lastSubgroup].items[lastItem];
faq
.groups[lastGroup]
.subgroups[lastSubgroup]
.items[lastItem]
.content = item.content + newLine;
}
} else if (line.indexOf('[not ready]') >= 0) {
// everything else is text of the last item
let item = faq.groups[lastGroup].subgroups[lastSubgroup].items[lastItem];
item.notReady = true;
}
}
// remove notReady items
faq.groups.forEach(g => {
g.subgroups.forEach(sg => {
sg.items = sg.items.filter(i => i.notReady !== true && i.content.length > 0)
})
})
if (configRemoveEmptyGroups) {
faq.groups.forEach(g => {
g.subgroups = g.subgroups.filter(sb => sb.items.length > 0)
})
faq.groups = faq.groups.filter(g => g.subgroups.length > 0)
}
//console.log(faq.groups[0]);
let data = JSON.stringify(faq, null, 2);
fs.writeFileSync('src/data/faq-parsed.json', data);
}
function slugify(value) {
return value
.normalize('NFD') // split an accented letter in the base letter and the acent
.replace(/[\u0300-\u036f]/g, '') // remove all previously split accents
.toLowerCase()
.trim()
.replace(/[^a-z0-9 ]/g, '') // remove all chars not letters, numbers and spaces (to be replaced)
.replace(/\s+/g, '-') // separator
}
parseFaq();
......@@ -35,7 +35,7 @@ export default function FaqItem({
className="text-gray-600 overflow-hidden transition-all duration-300 ease-in-out"
style={accordionOpen ? {maxHeight: accordion.current.scrollHeight, opacity: 1} : {maxHeight: 0, opacity: 0}}
>
<p className="pb-5 text-gray-800">{children}</p>
<div className="pb-5 text-gray-800">{children}</div>
</div>
</Component>
);
......
......@@ -2,3 +2,9 @@ button {
border: none;
background: transparent;
}
.table-of-contents a {
&:hover {
text-decoration: none;
}
}
\ No newline at end of file
......@@ -81,3 +81,10 @@ button:focus,
backdrop-filter: blur(3px);
-webkit-backdrop-filter: blur(3px);
}
.table-of-contents a {
color: black;
&:hover {
color: #3578e5;
}
}
......@@ -29,6 +29,7 @@
html, body {
overflow-x: hidden;
scroll-behavior: smooth;
}
.alert a,
......@@ -47,6 +48,19 @@ img {
color: red; /* color of alt text for images with invalid src url */
}
/* FAQList styles */
.toc-inline {
ul.table-of-contents, li {
list-style: none;
}
}
.faq-anchor {
position: relative;
top: -70px;
}
// import css-vars directly from mosaic theme
@import '~@stoplight/mosaic/themes/default.css';
.json-schema-viewer {
......
This diff is collapsed.
This diff is collapsed.
......@@ -2254,6 +2254,15 @@
dependencies:
"@types/node" "*"
"@types/jsdom@^16.2.6":
version "16.2.14"
resolved "https://registry.yarnpkg.com/@types/jsdom/-/jsdom-16.2.14.tgz#26fe9da6a8870715b154bb84cd3b2e53433d8720"
integrity sha512-6BAy1xXEmMuHeAJ4Fv4yXKwBDTGTOseExKE3OaHiNycdHdZw59KfYzrt0DkDluvwmik1HRt6QS7bImxUmpSy+w==
dependencies:
"@types/node" "*"
"@types/parse5" "*"
"@types/tough-cookie" "*"
"@types/json-schema@*", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8":
version "7.0.8"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.8.tgz#edf1bf1dbf4e04413ca8e5b17b3b7d7d54b59818"
......@@ -2291,16 +2300,16 @@
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==
"@types/parse5@*", "@types/parse5@^6.0.0":
version "6.0.3"
resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-6.0.3.tgz#705bb349e789efa06f43f128cef51240753424cb"
integrity sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==
"@types/parse5@^5.0.0":
version "5.0.3"
resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-5.0.3.tgz#e7b5aebbac150f8b5fdd4a46e7f0bd8e65e19109"
integrity sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw==
"@types/parse5@^6.0.0":
version "6.0.3"
resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-6.0.3.tgz#705bb349e789efa06f43f128cef51240753424cb"
integrity sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==
"@types/prop-types@*":
version "15.7.4"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.4.tgz#fcf7205c25dff795ee79af1e30da2c9790808f11"
......@@ -2311,6 +2320,13 @@
resolved "https://registry.yarnpkg.com/@types/raf-schd/-/raf-schd-4.0.1.tgz#1f9e03736f277fe9c7b82102bf18570a6ee19f82"
integrity sha512-Ha+EnKHFIh9EKW0/XZJPUd3EGDFisEvauaBd4VVCRPKeOqUxNEc9TodiY2Zhk33XCgzJucoFEcaoNcBAPHTQ2A==
"@types/react-dom@^17.0.0":
version "17.0.15"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.15.tgz#f2c8efde11521a4b7991e076cb9c70ba3bb0d156"
integrity sha512-Tr9VU9DvNoHDWlmecmcsE5ZZiUkYx+nKBzum4Oxe1K0yJVyBlfbq7H3eXjxXqJczBKqPGq3EgfTru4MgKb9+Yw==
dependencies:
"@types/react" "^17"
"@types/react-dom@^17.0.3":
version "17.0.13"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.13.tgz#a3323b974ee4280070982b3112351bb1952a7809"
......@@ -2327,6 +2343,15 @@
"@types/scheduler" "*"
csstype "^3.0.2"
"@types/react@^17", "@types/react@^17.0.1":
version "17.0.44"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.44.tgz#c3714bd34dd551ab20b8015d9d0dbec812a51ec7"
integrity sha512-Ye0nlw09GeMp2Suh8qoOv0odfgCoowfM/9MG6WeRD60Gq9wS90bdkdRtYbRkNhXOpG4H+YXGvj4wOWhAC0LJ1g==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
csstype "^3.0.2"
"@types/react@^17.0.3":
version "17.0.40"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.40.tgz#dc010cee6254d5239a138083f3799a16638e6bad"
......@@ -2353,6 +2378,11 @@
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==
"@types/tough-cookie@*":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.1.tgz#8f80dd965ad81f3e1bc26d6f5c727e132721ff40"
integrity sha512-Y0K95ThC3esLEYD6ZuqNek29lNX2EM1qxV8y2FTLUB0ff5wWrk7az+mLrnNFUnaXcgKye22+sFBRXOgpPILZNg==
"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2", "@types/unist@^2.0.3":
version "2.0.6"
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d"
......@@ -2507,7 +2537,7 @@ acorn-import-assertions@^1.7.6:
resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9"
integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==
acorn-jsx@^5.0.1:
acorn-jsx@^5.0.1, acorn-jsx@^5.3.1:
version "5.3.2"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==
......@@ -2546,6 +2576,11 @@ acorn@^8.0.4, acorn@^8.4.1:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.4.1.tgz#56c36251fc7cabc7096adc18f05afe814321a28c"
integrity sha512-asabaBSkEKosYKMITunzX177CXxQ4Q8BSSzMTKD+FefUhipQC70gfW5SiUDhYQ3vk8G+81HqQk7Fv9OXwwn9KA==
acorn@^8.0.5:
version "8.7.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf"
integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==
address@^1.0.1, address@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/address/-/address-1.1.2.tgz#bf1116c9c758c51b7a933d296b72c221ed9428b6"
......@@ -3620,6 +3655,11 @@ core-js@^3.18.0:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.19.2.tgz#ae216d7f4f7e924d9a2e3ff1e4b1940220f9157b"
integrity sha512-ciYCResnLIATSsXuXnIOH4CbdfgV+H1Ltg16hJFN7/v6OxqnFr/IFGeLacaZ+fHLAm0TBbXwNK9/DNBzBUrO/g==
core-js@^3.8.3:
version "3.21.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.21.1.tgz#f2e0ddc1fc43da6f904706e8e955bc19d06a0d94"
integrity sha512-FRq5b/VMrWlrmCzwRrpDYNxyHP9BcAZC+xHJaqTgIE5091ZV1NTmyh0sGOg5XqpnHvR0svdy0sv1gWA1zmhxig==
core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
......@@ -8635,6 +8675,20 @@ react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
react-jsx-parser@^1.29.0:
version "1.29.0"
resolved "https://registry.yarnpkg.com/react-jsx-parser/-/react-jsx-parser-1.29.0.tgz#12f9d42675bfaa50f818259c5304478ec8bb80f1"
integrity sha512-u0svZd0UsPffRrIK0sTbox54jhEbTmg6ED9ob5FQahp1DeOpd2Rq+KiSTIFNYkZUL+WZi4Ntia/Oj5T4lDJafQ==
dependencies:
"@types/jsdom" "^16.2.6"
acorn "^8.0.5"
acorn-jsx "^5.3.1"
browserslist "^4.14.5"
core-js "^3.8.3"
optionalDependencies:
"@types/react" "^17.0.1"
"@types/react-dom" "^17.0.0"
react-loadable-ssr-addon-v5-slorber@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/react-loadable-ssr-addon-v5-slorber/-/react-loadable-ssr-addon-v5-slorber-1.0.1.tgz#2cdc91e8a744ffdf9e3556caabeb6e4278689883"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment