Broken links in README.md
Yudai-Tomita opened this issue · 2 comments
Yudai-Tomita commented
README.md にて各記事のリンクに「./article」が足りていないのでリンク切れを起こしているようなのですが、まとめて修正してしまってよろしいでしょうか。
(※archiveを除く)
実はCI/CDで使ってますといったような特殊な事情がありましたら教えてください。
修正例:
(./vm/linux-expand-os-disk.md) → (./articles/vm/linux-expand-os-disk.md)
juyamagu commented
ご指摘ありがとうございます。
実は README は自動生成したいねという話も議題にあがっていて、簡単に次のようなプログラムを書いていたところです。これに関しては別の issue を立てようと思いますので、#22 に関しては手動での修正で問題ないと思います。
const path = require("path");
const sourceFolder = "articles";
const glob = require("glob");
const fs = require('fs');
function markdownLink(mdPath) {
const content = fs.readFileSync(mdPath, 'utf8');
const regexp = /title:(.*)$/gim;
const res = regexp.exec(content);
const title = res ? res[1].trim().replace(/^"(.+)"$/, '$1') : path.basename(mdPath);
return `[${title}](./${mdPath})`
}
function markdownLinksOf(category) {
const catDir = path.join(sourceFolder, `/${category}`);
const mdPattern = path.join(catDir, '/*.md');
const result = glob.sync(mdPattern).map(mdPath => {
return `- ${markdownLink(mdPath)}`
}).join("\n");
return result === "" ? "- comming soon" : result;
}
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
const tolower = (str) => str.toLowerCase();
const categories = [
"information",
"vm",
"storage",
"network",
"other",
"archive",
].map(tolower);
const readmeStr = `# blog
日本マイクロソフト Azure IaaS Core サポート チームのブログです。
[https://jpaztech.github.io/blog/](https://jpaztech.github.io/blog/)
${categories.map(category => {
return `## ${capitalize(category)}\n` + markdownLinksOf(category);
}).join("\n\n")}
`
console.log(readmeStr);
Yudai-Tomita commented
承知いたしました。明日あたりにプルリク送ります。