diff --git a/docs/.vitepress/transformer.ts b/docs/.vitepress/transformer.ts index 2eb22ea5b..289c0014d 100644 --- a/docs/.vitepress/transformer.ts +++ b/docs/.vitepress/transformer.ts @@ -136,14 +136,14 @@ export function transformer(): Plugin { !id.includes('posts') && !id.includes('other') ) { - const header = getHeader(id) + const header = getHeader(_id) const contents = transform(code) if (_id === 'beginners-guide.md') { const _contents = transformGuide(contents) return header + _contents } - return header + contents + return header + transformLinks(contents) } } } @@ -155,8 +155,7 @@ function getHeader(id: string) { const description = '
' - const _id = basename(id) - const data = headers[_id] + const data = headers[id] let header = '---\n' header += `title: "${data.title}"\n` header += `description: ${data.description}\n` @@ -185,15 +184,17 @@ export function transformGuide(text: string): string { function replaceUnderscore(text: string): string { const pattern = /\/#[\w\-]+(?:_[\w]+)*/g const matches = text.match(pattern) || [] + let _text = text for (const match of matches) { const replacement = match.replace(/_/g, '-') - text = text.replace(match, replacement) + _text = _text.replace(match, replacement) } - return text + return _text } export function transform(text: string): string { let _text = text + // Transform reddit index links .replace( /\*\*\[◄◄ Back to Wiki Index\]\(https:\/\/www\.reddit\.com\/r\/FREEMEDIAHECKYEAH\/wiki\/index\)\*\*\n/gm, '' @@ -206,11 +207,13 @@ export function transform(text: string): string { /\*\*\[Table of Contents\]\(https?:\/\/.*?ibb\.co.*\)\*\* - For mobile users\n/gm, '' ) + // Remove extra lines .replace(/\*\*\*\n\*\*\*\n\*\*\*\n\*\*\*\n\n\n\*\*\*\n\*\*\*\n\n/gm, '') .replace(/\*\*\*\n\*\*\*\n\*\*\*\n\*\*\*\n\n\n\*\*\*\n\*\*\* \n\n/gm, '') .replace(/\*\*\*\n\*\*\*\n\*\*\*\n\n\n\*\*\*\n\*\*\*\n\n/gm, '') .replace(/\*\*\*\n\*\*\*\n\*\*\*\n\*\*\*\n\n\n\*\*\*\n\n/gm, '') .replace(/\*\*\*\n\*\*\*\n\n\n\*\*\*\n\n/gm, '') + // Transform reddit links .replace(/https:\/\/www.reddit.com\/r\/FREEMEDIAHECKYEAH\/wiki\/ai/g, '/ai') .replace( /https:\/\/www.reddit.com\/r\/FREEMEDIAHECKYEAH\/wiki\/adblock-vpn-privacy/g, @@ -308,6 +311,7 @@ export function transform(text: string): string { /https:\/\/github.com\/nbats\/FMHYedit\/blob\/main\/base64.md#/g, '/base64/#' ) + // Remove extra characters .replace(/\/#wiki_/g, '/#') .replace(/#wiki_/g, '/#') .replace(/.25BA_/g, '') @@ -323,14 +327,17 @@ export function transform(text: string): string { .replace(/# ►/g, '##') .replace(/## ▷/g, '###') .replace(/####/g, '###') + // Replace emojis .replace(/⭐/g, ':star:') .replace(/🌐/g, ':globe-with-meridians: ') - .replace(/↪ /g, ':repeat-button: ') + .replace(/↪/g, ':repeat-button: ') + // Replace note/warning/tip .replace(/^\*\*Note\*\* - (.+)$/gm, ':::tip\n$1\n:::') .replace(/^\* \*\*Note\*\* - (.+)$/gm, ':::tip\n$1\n:::') .replace(/^Note - (.+)$/gm, ':::tip\n$1\n:::') .replace(/^\*\*Warning\*\* - (.+)$/gm, ':::warning\n$1\n:::') .replace(/^\*\s([^*])/gm, '- $1') + // Replace links .replace( /\/storage\/#encode--decode_urls/g, '/storage/#encode--decode-urls' @@ -348,5 +355,16 @@ export function transform(text: string): string { /(.+?) site or extension\.\n/gm, 'Click on the texts to copy them decoded.\n' ) + + return _text +} + +function transformLinks(text: string): string { + const _text = text + // Transform Discord links to icons + .replace( + /\[Discord\]\(([^\)]*?)\)/gm, + '' + ) return _text } diff --git a/tsconfig.json b/tsconfig.json index b80a29a16..99bfda3e2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,32 +1,44 @@ { - "extends": "./.nitro/types/tsconfig.json" - // "compilerOptions": { - // "verbatimModuleSyntax": true, - // "baseUrl": ".", - // "module": "esnext", - // "target": "esnext", - // "lib": ["DOM", "ESNext"], - // "strict": true, - // "jsx": "preserve", - // "esModuleInterop": true, - // "skipLibCheck": true, - // "moduleResolution": "node", - // "resolveJsonModule": true, - // "noUnusedLocals": true, - // "strictNullChecks": true, - // "forceConsistentCasingInFileNames": true, - // "sourceMap": true, - // "isolatedModules": true - // }, - // "include": [ - // "**/*.vue", - // "**/*.tsx", - // "**/*.ts", - // ".vitepress/**/**/*.ts", - // ".vitepress/**/**/*.tsx", - // ".vitepress/**/**/*.vue" - // ], - // "exclude": ["**/node_modules/**", "dist/**"], - // "extensions": [".js", ".ts", ".tsx", ".jsx", ".vue"], - // "allowSyntheticDefaultImports": true + "extends": "./.nitro/types/tsconfig.json", + "compileroptions": { + "verbatimmodulesyntax": true, + "baseurl": ".", + "module": "esnext", + "target": "esnext", + "lib": [ + "dom", + "esnext" + ], + "strict": true, + "jsx": "preserve", + "esmoduleinterop": true, + "skiplibcheck": true, + "moduleresolution": "node", + "resolvejsonmodule": true, + "nounusedlocals": true, + "strictnullchecks": true, + "forceconsistentcasinginfilenames": true, + "sourcemap": true, + "isolatedmodules": true + }, + "include": [ + "**/*.vue", + "**/*.tsx", + "**/*.ts", + ".vitepress/**/**/*.ts", + ".vitepress/**/**/*.tsx", + ".vitepress/**/**/*.vue" + ], + "exclude": [ + "**/node_modules/**", + "dist/**" + ], + "extensions": [ + ".js", + ".ts", + ".tsx", + ".jsx", + ".vue" + ], + "allowSyntheticDefaultImports": true }