Skip to content

Commit 0169caa

Browse files
chore(docs): update deps and convert config to typscript
1 parent 864ba45 commit 0169caa

File tree

6 files changed

+6533
-7652
lines changed

6 files changed

+6533
-7652
lines changed

.vscode/tabaqa.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
"retif",
1414
"taqwim",
1515
"Unparser"
16-
]
16+
],
17+
"search.exclude": {
18+
"**/node_modules": true,
19+
"**/vendor": true,
20+
"**/bower_components": true,
21+
"**/.git": true,
22+
"**/tests": true,
23+
"**/.vscode": true,
24+
"**/out/**": true,
25+
"package-lock.json": true,
26+
"**/dist": true,
27+
"**/build": true,
28+
"**/coverage": true
29+
}
1730
}
1831
}
Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
34
import container from 'markdown-it-container';
45
import markdownItAttrs from 'markdown-it-attrs';
6+
import { defineConfig } from 'vitepress';
7+
import type { MarkdownItAsync } from 'markdown-it-async';
8+
import type { RenderRule } from 'markdown-it/lib/renderer.mjs';
9+
type ContainerArguments = [
10+
typeof container,
11+
string,
12+
{
13+
render: RenderRule,
14+
marker?: string;
15+
}
16+
];
517

6-
const getChildrenRules = (directoryName) => {
7-
const rules = fs.readdirSync(path.resolve(__dirname, `../rules/${directoryName}`));
18+
const currentDirectory = path.dirname(fileURLToPath(import.meta.url));
19+
const getChildrenRules = (directoryName: string) => {
20+
const rules = fs.readdirSync(path.resolve(currentDirectory, `../rules/${directoryName}`));
821
const items = [];
922
for (const rule of rules) {
1023
const ruleName = rule.replace('.md', '');
@@ -17,12 +30,12 @@ const getChildrenRules = (directoryName) => {
1730
};
1831

1932
const getRules = () => {
20-
const rulesFolderContent = fs.readdirSync(path.resolve(__dirname, '../rules'));
33+
const rulesFolderContent = fs.readdirSync(path.resolve(currentDirectory, '../rules'));
2134

2235
const items = [];
2336
for (const item of rulesFolderContent) {
2437
// Process directories only
25-
if (!fs.lstatSync(path.resolve(__dirname, `../rules/${item}`)).isDirectory()) {
38+
if (!fs.lstatSync(path.resolve(currentDirectory, `../rules/${item}`)).isDirectory()) {
2639
continue;
2740
}
2841

@@ -35,20 +48,24 @@ const getRules = () => {
3548
return items;
3649
};
3750

38-
const createRuleContainer = function (klass, defaultTitle, md) {
51+
const createRuleContainer = function (
52+
className: string,
53+
defaultTitle: string,
54+
md: MarkdownItAsync
55+
): ContainerArguments {
3956
return [
4057
container,
41-
klass,
58+
className,
4259
{
4360
render(tokens, index) {
4461
const token = tokens[index];
4562
const info = token.info
4663
.trim()
47-
.slice(klass.length)
64+
.slice(className.length)
4865
.trim();
4966
if (token.nesting === 1) {
5067
const title = md.renderInline(info || defaultTitle);
51-
return `<div class="${klass} rule-container custom-block"><p class="rule-block-title">${title}</p>\n`;
68+
return `<div class="${className} rule-container custom-block"><p class="rule-block-title">${title}</p>\n`;
5269
}
5370
return '</div>\n';
5471
},
@@ -57,20 +74,24 @@ const createRuleContainer = function (klass, defaultTitle, md) {
5774
];
5875
};
5976

60-
const createExampleContainer = function (klass, defaultTitle, md) {
77+
const createExampleContainer = function (
78+
className: string,
79+
defaultTitle: string,
80+
md: MarkdownItAsync
81+
): ContainerArguments {
6182
return [
6283
container,
63-
klass,
84+
className,
6485
{
6586
render(tokens, index) {
6687
const token = tokens[index];
6788
const info = token.info
6889
.trim()
69-
.slice(klass.length)
90+
.slice(className.length)
7091
.trim();
7192
if (token.nesting === 1) {
7293
const title = md.renderInline(info || defaultTitle);
73-
return `<div class="${klass} custom-block"><p class="custom-block-title">${title}</p>\n`;
94+
return `<div class="${className} custom-block"><p class="custom-block-title">${title}</p>\n`;
7495
}
7596
return '</div>\n';
7697
},
@@ -134,17 +155,18 @@ const getSidebarData = () => {
134155
];
135156
};
136157

137-
export default {
158+
const config = defineConfig({
138159
title: 'Documentation',
139160
description: 'Documentation for PHPTaqwim',
140161
base: '/docs/',
162+
cleanUrls: true,
141163
themeConfig: {
142164
siteTitle: 'PHPTaqwim',
143165
logo: './logo.png',
144166
outline: [2, 4],
145-
lastUpdated: true,
146-
cleanUrls: 'without-subfolders',
147-
167+
lastUpdated: {
168+
text: 'Last Updated',
169+
},
148170
socialLinks: [
149171
{
150172
icon: 'github',
@@ -195,4 +217,6 @@ export default {
195217
.use(markdownItAttrs);
196218
},
197219
},
198-
};
220+
});
221+
222+
export default config;

eslint.config.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ export default [
88
'eqeqeq': 'warn',
99
'no-throw-literal': 'warn',
1010
'semi': 'off',
11-
12-
// This rule is causing an error:
13-
// `Cannot read properties of undefined (reading 'decoration')` error
14-
// Disable it until it's fixed
15-
'unicorn/expiring-todo-comments': 'off',
16-
1711
'unicorn/prevent-abbreviations': [
1812
'warn',
1913
{
2014
checkFilenames: false,
2115
},
2216
],
17+
18+
// This rule is causing an error:
19+
// `Cannot read properties of undefined (reading 'decoration')` error
20+
// Disable it until it's fixed
21+
'unicorn/expiring-todo-comments': 'off',
22+
'jsonc/no-useless-escape': 'off',
2323
},
2424
},
2525
];

0 commit comments

Comments
 (0)