Skip to content

Commit

Permalink
Fix a couple of images
Browse files Browse the repository at this point in the history
Also, add image URL checking to the link checker
  • Loading branch information
josh-heyer committed Sep 5, 2024
1 parent 0920771 commit c66ad72
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ On the Set Up Identity Provider page:

For example:

![](../images/nameID.png)
![](images/nameID.png)
3. In the **SAML settings** section, enter the configuration information for your preferred SAML identity provider:

| Field | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ log in to the EDB container registry, for example, through `docker login` or a
In the [repos page in EDB](https://www.enterprisedb.com/repos-downloads),
is an EDB Repos 2.0 section where a repo token appears obscured.

![EDB Repo Portal](images/edb-repo-portal.png)
![EDB Repo Portal](../images/edb-repo-portal.png)

Next to the repo token is a **Copy Token** button to copy the token and an eye icon
for looking at the content of the token.
Expand Down
49 changes: 42 additions & 7 deletions tools/automation/actions/link-check/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import GithubSlugger from "github-slugger";
import toVfile from "to-vfile";
const { read, write } = toVfile;

const imageExts = [".png", ".svg", ".jpg", ".jpeg", ".gif"];
const docsUrl = "https://www.enterprisedb.com/docs";
// add path here to ignore link warnings
const noWarnPaths = [
Expand Down Expand Up @@ -158,6 +159,30 @@ async function main() {
await scanner.run(ast, input);
}

const imageFiles = await glob(
imageExts.flatMap((ext) => [
"product_docs/**/*" + ext,
"advocacy_docs/**/*" + ext,
]),
);

for (const sourcePath of imageFiles) {
const metadata = {
canonical: fsPathToURLPath(sourcePath),
index: false,
slugs: [],
redirects: [],
source: sourcePath,
};
allValidUrlPaths.set(metadata.canonical, metadata);
if (isVersioned(sourcePath)) {
const splitPath = metadata.canonical.split(path.posix.sep);
metadata.product = splitPath[1];
metadata.version = splitPath[2];
allValidUrlPaths.set(latestVersionURLPath(sourcePath), metadata);
}
}

// compile product versions
const productVersions = {};

Expand Down Expand Up @@ -356,9 +381,16 @@ function cleanup() {

const mapUrlToCanonical = (url, position) => {
let test = normalizeUrl(url, metadata.canonical, metadata.index);
if (
test.href ===
docsUrl + "/edb-postgres-ai/analytics/images/level-50.png"
)
debugger;
if (!test.href.startsWith(docsUrl)) return url;
if (test.href === docsUrl) return url;
if (path.posix.extname(test.pathname)) return url;
const ext = path.posix.extname(test.pathname);
const isImageUrl = imageExts.includes(ext);
if (ext && !isImageUrl) return url;

metadata.linksChecked = metadata.linksChecked || 0 + 1;

Expand Down Expand Up @@ -440,7 +472,7 @@ function cleanup() {
return url;
};

visitParents(tree, ["link", "element"], (node) => {
visitParents(tree, ["link", "image", "element"], (node) => {
try {
if (
node.type === "element" &&
Expand All @@ -451,7 +483,7 @@ function cleanup() {
node.properties.href,
node.position,
);
else if (node.type === "link")
else if (node.type === "link" || node.type === "image")
node.url = mapUrlToCanonical(node.url, node.position);
} catch (e) {
file.message(e, node.position);
Expand Down Expand Up @@ -494,11 +526,14 @@ function fsPathToURLPath(fsPath) {
// 2. strip trailing index.mdx
// 3. strip trailing .mdx
// 4. strip trailing /
// URL encode
const docsLocations = /product_docs\/docs|advocacy_docs/;
return fsPath
.split(docsLocations)[1]
.replace(/\/index\.mdx$|\.mdx$/, "")
.replace(/\/$/, "");
return encodeURI(
fsPath
.split(docsLocations)[1]
.replace(/\/index\.mdx$|\.mdx$/, "")
.replace(/\/$/, ""),
);
}

function latestVersionURLPath(fsPath) {
Expand Down

0 comments on commit c66ad72

Please sign in to comment.