mirror of
https://github.com/lainbo/component-party.git
synced 2026-04-05 13:09:03 +08:00
add framework logos
This commit is contained in:
@@ -2,6 +2,7 @@ import fs from 'fs';
|
||||
import getDocContent from './getDocContent.js';
|
||||
|
||||
export default function generateIndexPage() {
|
||||
console.log('generateIndexPage')
|
||||
const template = fs.readFileSync('scripts/templates/index.base.md', 'utf8');
|
||||
fs.writeFileSync('src/pages/index.md', template.replace('<slot/>', getDocContent()), 'utf-8');
|
||||
}
|
||||
|
||||
@@ -32,22 +32,25 @@ export default function getDocContent() {
|
||||
// write subsection title
|
||||
fileContent += `## ${subSectionDirTitle}\n`;
|
||||
|
||||
const frameworkDirs = fs.readdirSync(`${sectionDir}/${subSectionDir}`).filter((path) => !path.includes('.'));
|
||||
|
||||
for (const frameworkDir of frameworkDirs) {
|
||||
const framework = FRAMEWORKS.find((f) => f.id === frameworkDir);
|
||||
fileContent += `### ${framework.title}\n`;
|
||||
const files = fs.readdirSync(`${sectionDir}/${subSectionDir}/${frameworkDir}`);
|
||||
|
||||
for (const framework of FRAMEWORKS) {
|
||||
function addSnippetWrap(content) {
|
||||
return `\`\`\`${framework.ext}\n${content}\n\`\`\`\n\n`;
|
||||
}
|
||||
const imgTag = framework.img ? `<img src="${framework.img}" width="20" height="20" class="framework-logo" />` : '';
|
||||
fileContent += `### ${imgTag} ${framework.title}\n`;
|
||||
|
||||
for (const file of files) {
|
||||
const parsedFile = path.parse(file);
|
||||
const currentFileContent = fs.readFileSync(`${sectionDir}/${subSectionDir}/${frameworkDir}/${file}`);
|
||||
const frameworkFileContent = parsedFile.ext === '.md' ? `${currentFileContent}\n` : addSnippetWrap(currentFileContent);
|
||||
fileContent += frameworkFileContent;
|
||||
const frameworkDirPath = `${sectionDir}/${subSectionDir}/${framework.id}`;
|
||||
if (fs.existsSync(frameworkDirPath)) {
|
||||
const files = fs.readdirSync(frameworkDirPath);
|
||||
|
||||
for (const file of files) {
|
||||
const parsedFile = path.parse(file);
|
||||
const currentFileContent = fs.readFileSync(`${frameworkDirPath}/${file}`);
|
||||
const frameworkFileContent = parsedFile.ext === '.md' ? `${currentFileContent}\n` : addSnippetWrap(currentFileContent);
|
||||
fileContent += frameworkFileContent;
|
||||
}
|
||||
} else {
|
||||
fileContent += `<pre>Oops, missing snippet ! You can contribute <a href="https://github.com/matschik/component-party/tree/main/${sectionDir}/${subSectionDir}">here</a> to fill this snippet.</pre>\n`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user