Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tools/serve-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Apr 11, 2024
2 parents 8dfcb9d + d431c2f commit 137f64a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
21 changes: 12 additions & 9 deletions lib/pages.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
const pandoc = require("./pandoc");
const fs = require("fs");

const VOCAB = require("../package.json").name;
const PKG = require("../package.json");
const GITHUB_REPO = PKG.repository.url.match(/^git\+(.*?)\.git$/)[1];
const REPO = process.argv[process.argv.length - 1];

function file(dir, title, filename) {
console.log(`${dir}/${filename}`);
pandoc(
{
stdin: fs.createReadStream(`${__dirname}/../${dir}/${filename}`),
stdin: fs.createReadStream(`${dir}/${filename}`),
stdout: fs.createWriteStream(
`_site/${dir}/${filename === "README.md" ? "index.html" : filename.replace(/\.md$/, ".html")}`,
),
},
{
"-c": `/${VOCAB}/styles/style.css`,
"-c": `/${PKG.name}/styles/style.css`,
"-F": `${__dirname}/md2html.js`,
"-M": `title=${REPO}${title ? " - " + title : ""}`,
"-V": [`github-repo=${GITHUB_REPO}`, `github-path=${dir}/${filename}`],
"--template": "assets/template",
},
);
}

function directory(dir, title) {
if (fs.existsSync(`${__dirname}/../${dir}`)) {
fs.cpSync(`${__dirname}/../${dir}`, `_site/${dir}`, {
recursive: true,
});
fs.readdirSync(`${__dirname}/../${dir}`)
if (fs.existsSync(dir)) {
if (dir !== ".")
fs.cpSync(`${dir}`, `_site/${dir}`, {
recursive: true,
});
fs.readdirSync(dir)
.filter((fn) => fn.endsWith(".md"))
.forEach(function (filename) {
file(dir, title, filename);
Expand All @@ -39,7 +42,7 @@ fs.cpSync(`${__dirname}/../assets/styles`, `_site/styles`, {
recursive: true,
});

file(".", "", "README.md");
directory(".", "");
directory("docs", "Documents");
directory("examples", "Examples");
directory("vocabularies", "Vocabularies");
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"url": "git+https://github.com/oasis-tcs/odata-vocabularies.git"
},
"files": [
"lib/*"
"lib/*",
"assets/*"
],
"bin": {
"odata-vocab2md": "lib/cli.js"
Expand Down

0 comments on commit 137f64a

Please sign in to comment.