Skip to content

Commit

Permalink
migrate to vue-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainpolletvillard committed Jul 31, 2019
1 parent a42c8c6 commit 5dbbe81
Show file tree
Hide file tree
Showing 148 changed files with 10,956 additions and 111 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VUE_APP_I18N_LOCALE=en
VUE_APP_I18N_FALLBACK_LOCALE=en
36 changes: 36 additions & 0 deletions build/generate-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const fs = require('fs');

const localesMessages = {
"fr": "Ce cookbook est aussi disponible [en Français]",
"en": "This cookbook is also available [in English]"
}

const foreach = (arr, fn) => arr.map(fn).join('\n');

const generateIndex = (locale, relativePathToPages) => {
const index = require(`../static/pages/${locale}/index.json`);
return `## Index
${foreach(index.chapters, chapter => `
### ${ chapter.title }
${foreach(chapter.sections, section =>
`- [${section.title}](${relativePathToPages}/${locale}/${section.link}.md)`
)}`)}
${Object.keys(localesMessages)
.filter(otherLocale => otherLocale !== locale)
.map(otherLocale => `${localesMessages[otherLocale]}(${relativePathToPages}/${otherLocale}/index.md).`)
.join('\n')
}`
}

const replaceContent = (file, content) => {
fs.writeFileSync(file, fs.readFileSync(file).toString().replace(
/## Index[\s\S]*<!--- END_INDEX -->/,
content + `\n\n<!--- END_INDEX -->`)
);
}

replaceContent('README.md', generateIndex("en", "static/pages"))
replaceContent('static/pages/en/index.md', generateIndex("en", ".."))
replaceContent('static/pages/fr/index.md', generateIndex("fr", ".."))
Loading

0 comments on commit 5dbbe81

Please sign in to comment.