Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix displaying images in preview #461

Merged
merged 18 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ jobs:
continue-on-error: true

- name: Start
run: docker run -t -v wikiGDriveExample:/data -v /home/wikigdrive/service_account.json:/service_account.json -v "/var/www/dev.wikigdrive.com:/usr/src/app/dist/hugo" wikigdrive-test wikigdrive --service_account /service_account.json --share_email [email protected] --workdir /data pull 0AIkOKXbzWCtSUk9PVA
run: docker run -t -v wikiGDriveExample:/data -v /home/wikigdrive/service_account.json:/service_account.json -v "/var/www/dev.wikigdrive.com:/usr/src/app/dist/hugo" wikigdrive-test wikigdrive --service_account /service_account.json --share_email [email protected] --transform_subdir / --workdir /data pull 0AIkOKXbzWCtSUk9PVA
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ content
hugo/resources
hugo_stats.json

.wgd-directory.yaml
.tree.json
.wgd-local-links.csv
.wgd-local-log.csv
59 changes: 59 additions & 0 deletions apps/wgd-action-runner/site/navigation2menu.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/node

/**
* In order to generate menu.en.json from markdown file run:
*
* cat content/navigation.md | ./navigation2menu.js > config/_default/menu.en.json
*/

// Work on POSIX and Windows
import fs from 'node:fs';
const stdinBuffer = fs.readFileSync(0); // STDIN_FILENO = 0

const markdown = stdinBuffer.toString();

let weight = 10;

const parentStack = [];
const menu = [];

let lastContent = 'First line';

for (const line of markdown.split('\n')) {
if (!line.match(/^ *\* /)) {
continue;
}
const indentPart = line.replace(/(^ *\* ).*/, '$1');
const markdownLink = line.substring(indentPart.length);
const matched = markdownLink.match(/\[([^\]]+)]\(([^)]+)\)/);
if (!matched) {
console.warn(`Warning: navigation.md menu has "${markdownLink}" without url near: "${lastContent}"`);
continue;
}
const [_, name, pageRef] = matched;
const level = (indentPart.length - 2)/3;

while (parentStack.length > level) {
parentStack.pop();
}

const identifier = pageRef;

if (pageRef.startsWith('http://') || pageRef.startsWith('https://') || fs.existsSync('./content/' + pageRef)) {
menu.push({
identifier,
name,
pageRef,
parent: parentStack[parentStack.length - 1],
weight
});
} else {
console.warn(`Warning: navigation.md menu has "${markdownLink}" without file: "${pageRef}"`);
}

weight += 10;
parentStack.push(identifier);
lastContent = markdownLink;
}

console.log(JSON.stringify({ main: menu }, null, 4));
Loading
Loading