diff --git a/scripts/generate-theme-doc.ts b/scripts/generate-theme-doc.ts index 6fa3e60..d11ea41 100644 --- a/scripts/generate-theme-doc.ts +++ b/scripts/generate-theme-doc.ts @@ -2,9 +2,15 @@ import fs from "fs"; import { themes } from '../themes/index'; const TARGET_FILE = "./themes/README.md"; + // Function to generate the markdown for themes -function generateThemeMarkdown(username: string, theme: string, itemsPerRow: number = 3): string { - return `\`${theme}\` [![${theme}](https://github-readme-profile-alpha.vercel.app/api?username=${username}&theme=${theme})](https://github-readme-profile-alpha.vercel.app/api?username=${username}&theme=${theme})`; +function generateThemeMarkdown(theme: string): string { + return `\`${theme}\` ![${theme}][${theme}]`; +} + +// Function to generate themes preview link +function generateThemeLink(username: string, theme: string): string { + return `[${theme}]: https://github-readme-profile-alpha.vercel.app/api?username=${username}&theme=${theme}` } // Function to generate README.md content @@ -15,10 +21,17 @@ function generateReadme(username: string): string { let themesPreviewTable = ''; for (let i = 0; i < availableThemes.length; i += itemsPerRow) { const themesSlice = availableThemes.slice(i, i + itemsPerRow); - const row = themesSlice.map(theme => generateThemeMarkdown(username, theme)).join(' | '); + const row = themesSlice.map(theme => generateThemeMarkdown(theme)).join(' | '); themesPreviewTable += `| ${row} |\n`; } + let themesPreviewLink = ''; + for (let i = 0; i < availableThemes.length; i += 1) { + const themesSlice = availableThemes.slice(i, i + 1); + const row = themesSlice.map(theme => generateThemeLink(username, theme)).join('\n'); + themesPreviewLink += `${row}\n`; + } + const readmeContent = ` ## Available Themes @@ -27,7 +40,7 @@ With inbuilt themes, you can customize the look of the card without doing any ma Use \`?theme=THEME_NAME\` parameter like so :- \`\`\`md -![GitHub Profile](https://github-readme-profile-alpha.vercel.app/api?username=${username}&theme=dark) +![GitHub Profile](https://gh-readme-profile.vercel.app/api?username=${username}&theme=dark) \`\`\` ## Themes Preview @@ -37,7 +50,8 @@ Use \`?theme=THEME_NAME\` parameter like so :- ${themesPreviewTable} Want to add a new theme? Consider reading the [contribution guidelines](/CONTRIBUTING.md#-themes-contribution) :D -`; + +${themesPreviewLink}`; return readmeContent; }