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

Allow to zoom images in docs on mouse click #816

Merged
merged 1 commit into from
Mar 3, 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
192 changes: 102 additions & 90 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ const { renderAnnouncementBar } = require("./src/components/ui/renderAnnouncemen
const versions = require("./versions.json");
const latestVersion = versions[0];
const versionsMap = {
..._.keyBy(
versions.map((item) => {
return {
label: item,
path: item,
};
}),
"label"
),
current: {
label: "Next",
path: "next",
},
..._.keyBy(
versions.map((item) => {
return {
label: item,
path: item,
};
}),
"label"
),
current: {
label: "Next",
path: "next",
},
};

let buildVersions = ["current"];
try {
buildVersions = require("./.build-versions.json");
buildVersions = require("./.build-versions.json");
} catch (error) {
//do nothing
//do nothing
}

const oldUrl = "https://pulsar.apache.org";
Expand All @@ -45,86 +45,86 @@ const math = require('remark-math');
const katex = require('rehype-katex');

const injectLinkParse = ([, prefix, , name, path]) => {
if (prefix == "javadoc") {
return {
link: javadocUrl + path,
text: name,
};
} else if (prefix == "github") {
return {
link: githubUrl + "/tree/master/" + path,
text: name,
};
} else if (prefix == "rest") {
return {
link: restApiUrl + "#" + path,
text: name,
};
} else if (prefix == "functions") {
return {
link: functionsApiUrl + "#" + path,
text: name,
};
} else if (prefix == "source") {
return {
link: sourceApiUrl + "#" + path,
text: name,
};
} else if (prefix == "sink") {
return {
link: sinkApiUrl + "#" + path,
text: name,
};
} else if (prefix == "packages") {
return {
link: packagesApiUrl + "#" + path,
text: name,
};
}

if (prefix == "javadoc") {
return {
link: javadocUrl + path,
text: name,
};
} else if (prefix == "github") {
return {
link: githubUrl + "/tree/master/" + path,
text: name,
};
} else if (prefix == "rest") {
return {
link: restApiUrl + "#" + path,
text: name,
};
} else if (prefix == "functions") {
return {
link: functionsApiUrl + "#" + path,
text: name,
};
} else if (prefix == "source") {
return {
link: sourceApiUrl + "#" + path,
text: name,
};
} else if (prefix == "sink") {
return {
link: path,
text: name,
link: sinkApiUrl + "#" + path,
text: name,
};
} else if (prefix == "packages") {
return {
link: packagesApiUrl + "#" + path,
text: name,
};
}

return {
link: path,
text: name,
};
};

const injectLinkParseForEndpoint = ([, info]) => {
let [method, path, suffix] = info.split("|");
let [method, path, suffix] = info.split("|");

if (!suffix) {
suffix = "";
}
if (!suffix) {
suffix = "";
}

let restPath = path.split("/");
const restApiVersion = restPath[2];
const restApiType = restPath[3];
const restBaseUrl = {
functions: functionsApiUrl,
source: sourceApiUrl,
sink: sinkApiUrl,
packages: packagesApiUrl,
transactions: transactionsApiUrl,
lookup: lookupApiUrl
}[restApiType] || restApiUrl;
let restPath = path.split("/");
const restApiVersion = restPath[2];
const restApiType = restPath[3];
const restBaseUrl = {
functions: functionsApiUrl,
source: sourceApiUrl,
sink: sinkApiUrl,
packages: packagesApiUrl,
transactions: transactionsApiUrl,
lookup: lookupApiUrl
}[restApiType] || restApiUrl;

let restUrl;
if (suffix.indexOf("?version=") >= 0) {
const suffixAndVersion = suffix.split("?version=")
restUrl = "version=" + suffixAndVersion[1] + "&apiversion=" + restApiVersion + "#" + suffixAndVersion[0];
if (suffixAndVersion[0].startsWith("operation/")) {
path += suffixAndVersion[0].slice("operation".length)
}
} else {
restUrl = "version=master&apiversion=" + restApiVersion + "#" + suffix;
if (suffix.startsWith("operation/")) {
path += suffix.slice("operation".length)
}
let restUrl;
if (suffix.indexOf("?version=") >= 0) {
const suffixAndVersion = suffix.split("?version=")
restUrl = "version=" + suffixAndVersion[1] + "&apiversion=" + restApiVersion + "#" + suffixAndVersion[0];
if (suffixAndVersion[0].startsWith("operation/")) {
path += suffixAndVersion[0].slice("operation".length)
}
} else {
restUrl = "version=master&apiversion=" + restApiVersion + "#" + suffix;
if (suffix.startsWith("operation/")) {
path += suffix.slice("operation".length)
}
}

return {
text: method + " " + path,
link: restBaseUrl + "?" + restUrl,
};
return {
text: method + " " + path,
link: restBaseUrl + "?" + restUrl,
};
};

/** @type {import('@docusaurus/types').Config} */
Expand Down Expand Up @@ -161,6 +161,16 @@ module.exports = {
colorMode: {
disableSwitch: true,
},
zoom: {
selector: '.markdown img',
background: {
light: '#fff',
dark: '#111'
},
config: {
// options you can specify via https://github.com/francoischalifour/medium-zoom#usage
}
},
navbar: {
title: "",
logo: {
Expand Down Expand Up @@ -343,11 +353,11 @@ module.exports = {
</a>
</div>
`,
},
],
},
],
copyright: `
},
],
},
],
copyright: `
<div>
<img class="footer-apache-logo" src="/img/feather-logo-white.svg" alt="" width="20">
The Apache Software Foundation
Expand Down Expand Up @@ -413,6 +423,7 @@ module.exports = {
require.resolve("./src/css/docs.css"),
require.resolve("./src/css/base-table.css"),
require.resolve("./src/css/typography.css"),
require.resolve("./src/css/image-zoom.css"),
require.resolve("./src/css/announcement-bar.css"),
require.resolve("./src/css/navbar.css"),
require.resolve("./src/css/footer.css"),
Expand All @@ -426,6 +437,7 @@ module.exports = {
],
],
plugins: [
'docusaurus-plugin-image-zoom',
[
"content-docs",
/** @type {import('@docusaurus/plugin-content-docs').Options} */
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"chokidar": "^3.5.3",
"clsx": "^1.1.1",
"compare-versions": "^4.1.3",
"docusaurus-plugin-image-zoom": "^1.0.1",
"execa": "^6.1.0",
"file-loader": "^6.2.0",
"font-awesome": "^4.7.0",
Expand Down
4 changes: 4 additions & 0 deletions src/css/image-zoom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.medium-zoom-overlay,
.medium-zoom-image--opened {
z-index: 999;
}
Loading
Loading