Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7b1b78d

Browse files
authored
Revert "Update generate-theme-doc.js (anuraghazra#3308)" (anuraghazra#3353)
This reverts commit28b6592.
1 parent28b6592 commit7b1b78d

File tree

1 file changed

+42
-48
lines changed

1 file changed

+42
-48
lines changed

‎scripts/generate-theme-doc.js‎

Lines changed: 42 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@ import fs from "fs";
22
import{themes}from"../themes/index.js";
33

44
constTARGET_FILE="./themes/README.md";
5-
constLINKS_FLAG_MAP={
6-
repo:"<!-- REPO_CARD_LINKS -->",
7-
stats:"<!-- STATS_CARD_LINKS -->",
8-
};
9-
constTABLE_FLAG_MAP={
10-
repo:"<!-- REPO_CARD_TABLE -->",
11-
stats:"<!-- STATS_CARD_TABLE -->",
12-
};
5+
constREPO_CARD_LINKS_FLAG="<!-- REPO_CARD_LINKS -->";
6+
constSTAT_CARD_LINKS_FLAG="<!-- STATS_CARD_LINKS -->";
7+
8+
constSTAT_CARD_TABLE_FLAG="<!-- STATS_CARD_TABLE -->";
9+
constREPO_CARD_TABLE_FLAG="<!-- REPO_CARD_TABLE -->";
1310

1411
constTHEME_TEMPLATE=`## Available Themes
1512
1613
<!-- DO NOT EDIT THIS FILE DIRECTLY -->
1714
1815
With inbuilt themes, you can customize the look of the card without doing any manual customization.
1916
20-
Use \`?theme=THEME_NAME\` parameter like so:
17+
Use \`?theme=THEME_NAME\` parameter like so :-
2118
2219
\`\`\`md
2320
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&theme=dark&show_icons=true)
@@ -29,44 +26,44 @@ Use \`?theme=THEME_NAME\` parameter like so:
2926
3027
| | | |
3128
| :--: | :--: | :--: |
32-
${TABLE_FLAG_MAP.stats}
29+
${STAT_CARD_TABLE_FLAG}
3330
3431
## Repo Card
3532
3633
> These themes work both for the Stats Card and Repo Card.
3734
3835
| | | |
3936
| :--: | :--: | :--: |
40-
${TABLE_FLAG_MAP.repo}
37+
${REPO_CARD_TABLE_FLAG}
4138
42-
${LINKS_FLAG_MAP.stats}
39+
${STAT_CARD_LINKS_FLAG}
40+
41+
${REPO_CARD_LINKS_FLAG}
4342
44-
${LINKS_FLAG_MAP.repo}
4543
4644
[add-theme]: https://github.com/anuraghazra/github-readme-stats/edit/master/themes/index.js
4745
4846
Want to add a new theme? Consider reading the [contribution guidelines](../CONTRIBUTING.md#themes-contribution) :D
4947
`;
5048

51-
constcreateMdLink=(theme,type)=>{
52-
constbaseLink=
53-
type==="repo"
54-
?"api/pin/?username=anuraghazra&repo=github-readme-stats"
55-
:"api?username=anuraghazra";
56-
return`\n[${theme}]: https://github-readme-stats.vercel.app/${baseLink}&cache_seconds=86400&theme=${theme}`;
49+
constcreateRepoMdLink=(theme)=>{
50+
return`\n[${theme}_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=${theme}`;
51+
};
52+
constcreateStatMdLink=(theme)=>{
53+
return`\n[${theme}]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=${theme}`;
5754
};
5855

59-
constgenerateLinks=(type)=>{
56+
constgenerateLinks=(fn)=>{
6057
returnObject.keys(themes)
61-
.map((name)=>createMdLink(name,type))
58+
.map((name)=>fn(name))
6259
.join("");
6360
};
6461

65-
constcreateTableItem=({ link, label})=>{
62+
constcreateTableItem=({ link, label, isRepoCard})=>{
6663
if(!link||!label){
6764
return"";
6865
}
69-
return`\`${label}\` ![${link}][${link}]`;
66+
return`\`${label}\` ![${link}][${link}${isRepoCard ?"_repo" :""}]`;
7067
};
7168

7269
constgenerateTable=({ isRepoCard})=>{
@@ -76,23 +73,22 @@ const generateTable = ({ isRepoCard }) => {
7673
);
7774

7875
for(leti=0;i<themesFiltered.length;i+=3){
79-
const[one,two,three]=themesFiltered.slice(i,i+3);
80-
81-
consttableItem1=createTableItem({link:one,label:one});
82-
consttableItem2=createTableItem({link:two,label:two});
83-
consttableItem3=createTableItem({link:three,label:three});
84-
85-
if(i+3>=themesFiltered.length){
86-
// If last row add your theme placeholder.
87-
if(!three){
88-
rows.push(
89-
`${tableItem1} |${tableItem2} | [Add your theme][add-theme] |`,
90-
);
91-
}else{
92-
rows.push(`| [Add your theme][add-theme] | | |`);
93-
}
94-
}else{
95-
rows.push(`|${tableItem1} |${tableItem2} |${tableItem3} |`);
76+
constone=themesFiltered[i];
77+
consttwo=themesFiltered[i+1];
78+
constthree=themesFiltered[i+2];
79+
80+
lettableItem1=createTableItem({link:one,label:one, isRepoCard});
81+
lettableItem2=createTableItem({link:two,label:two, isRepoCard});
82+
lettableItem3=createTableItem({link:three,label:three, isRepoCard});
83+
84+
if(three===undefined){
85+
tableItem3=`[Add your theme][add-theme]`;
86+
}
87+
rows.push(`|${tableItem1} |${tableItem2} |${tableItem3} |`);
88+
89+
// if it's the last row & the row has no empty space push a new row
90+
if(three&&i+3===themesFiltered.length){
91+
rows.push(`| [Add your theme][add-theme] | | |`);
9692
}
9793
}
9894

@@ -102,16 +98,16 @@ const generateTable = ({ isRepoCard }) => {
10298
constbuildReadme=()=>{
10399
returnTHEME_TEMPLATE.split("\n")
104100
.map((line)=>{
105-
if(line.includes(LINKS_FLAG_MAP.repo)){
106-
returngenerateLinks("repo");
101+
if(line.includes(REPO_CARD_LINKS_FLAG)){
102+
returngenerateLinks(createRepoMdLink);
107103
}
108-
if(line.includes(LINKS_FLAG_MAP.stats)){
109-
returngenerateLinks("stats");
104+
if(line.includes(STAT_CARD_LINKS_FLAG)){
105+
returngenerateLinks(createStatMdLink);
110106
}
111-
if(line.includes(TABLE_FLAG_MAP.repo)){
107+
if(line.includes(REPO_CARD_TABLE_FLAG)){
112108
returngenerateTable({isRepoCard:true});
113109
}
114-
if(line.includes(TABLE_FLAG_MAP.stats)){
110+
if(line.includes(STAT_CARD_TABLE_FLAG)){
115111
returngenerateTable({isRepoCard:false});
116112
}
117113
returnline;
@@ -120,5 +116,3 @@ const buildReadme = () => {
120116
};
121117

122118
fs.writeFileSync(TARGET_FILE,buildReadme());
123-
124-
console.log("README.md updated successfully!");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp