Skip to content

Commit ccabe04

Browse files
author
Allen Manning
authored
Merge pull request #4695 from quarto-dev/bug/index-links
Links aren't resolved in index.qmd on Confluence #4652
2 parents 901c2ff + c83eec2 commit ccabe04

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
lines changed

src/publish/confluence/confluence-helper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,14 @@ export const updateLinks = (
688688
}
689689
}
690690

691+
if (!documentFileName.endsWith(".xml")) {
692+
//this is a flattened index in a folder with contents
693+
const siteFilePathParent = `${documentFileName}/${linkFullFileName}`;
694+
if (fileMetadataTable[siteFilePathParent]) {
695+
siteFilePath = siteFilePathParent;
696+
}
697+
}
698+
691699
const sitePage: SitePage | null = fileMetadataTable[siteFilePath] ?? null;
692700

693701
if (sitePage) {

src/publish/confluence/confluence.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,13 +678,21 @@ async function publish(
678678

679679
changeList = flattenIndexes(changeList, metadataByFilename);
680680

681+
console.log("updateLinks");
682+
console.log("metadataByFilename", metadataByFilename);
683+
681684
const { pass1Changes, pass2Changes } = updateLinks(
682685
metadataByFilename,
683686
changeList,
684687
server,
685688
siteParent
686689
);
687690

691+
console.log("{ pass1Changes, pass2Changes }", {
692+
pass1Changes,
693+
pass2Changes,
694+
});
695+
688696
changeList = pass1Changes;
689697

690698
trace("changelist Pass 1", changeList);

tests/configure-test-env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ python_exists=$(command -v python)
1717
if [ -z $python_exists ]
1818
then
1919
python_exists=$(command -v python3)
20-
if [ -z python_exists]
20+
if [ -z python_exists]
2121
then
2222
echo "No python found in PATH - Check your PATH or install python add to PATH."
2323
fi

tests/unit/confluence.test.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3741,7 +3741,7 @@ const runUpdateLinks = () => {
37413741
fileName: "release-planning.xml",
37423742
};
37433743

3744-
const UPDATE_LINKS_INDEX: ContentUpdate = {
3744+
const UPDATE_LINK_TO_INDEX: ContentUpdate = {
37453745
contentChangeType: ContentChangeType.update,
37463746
id: "19890228",
37473747
version: null,
@@ -3758,6 +3758,23 @@ const runUpdateLinks = () => {
37583758
fileName: "release-planning.xml",
37593759
};
37603760

3761+
const UPDATE_SELF_LINK_FROM_INDEX: ContentUpdate = {
3762+
contentChangeType: ContentChangeType.update,
3763+
id: "fake-folder-id",
3764+
version: null,
3765+
title: "fake-folder-title",
3766+
type: "page",
3767+
status: "current",
3768+
ancestors: [{ id: "19759105" }],
3769+
body: {
3770+
storage: {
3771+
value: "<a href='index.qmd'>self</a>",
3772+
representation: "storage",
3773+
},
3774+
},
3775+
fileName: "folder",
3776+
};
3777+
37613778
const UPDATE_LINKS_SPECIAL_CHAR: ContentUpdate = {
37623779
contentChangeType: ContentChangeType.update,
37633780
id: "19890228",
@@ -3918,10 +3935,10 @@ const runUpdateLinks = () => {
39183935
});
39193936

39203937
test(suiteLabel("one_update_link_index"), async () => {
3921-
const changes: ConfluenceSpaceChange[] = [UPDATE_LINKS_INDEX];
3938+
const changes: ConfluenceSpaceChange[] = [UPDATE_LINK_TO_INDEX];
39223939
const rootURL = "fake-server/wiki/spaces/QUARTOCONF/pages";
39233940
const expectedUpdate: ContentUpdate = {
3924-
...UPDATE_LINKS_INDEX,
3941+
...UPDATE_LINK_TO_INDEX,
39253942
body: {
39263943
storage: {
39273944
value: `<a href=\'fake-server/wiki/spaces/QUARTOCONF/pages/fake-folder-id'>team</a>`,
@@ -3933,6 +3950,22 @@ const runUpdateLinks = () => {
39333950
check(expected, changes, fileMetadataTable, "fake-server", FAKE_PARENT);
39343951
});
39353952

3953+
test(suiteLabel("one_update_link_from_index"), async () => {
3954+
const changes: ConfluenceSpaceChange[] = [UPDATE_SELF_LINK_FROM_INDEX];
3955+
const rootURL = "fake-server/wiki/spaces/QUARTOCONF/pages";
3956+
const expectedUpdate: ContentUpdate = {
3957+
...UPDATE_SELF_LINK_FROM_INDEX,
3958+
body: {
3959+
storage: {
3960+
value: `<a href=\'fake-server/wiki/spaces/QUARTOCONF/pages/fake-index-id'>self</a>`,
3961+
representation: "storage",
3962+
},
3963+
},
3964+
};
3965+
const expected: ConfluenceSpaceChange[] = [expectedUpdate];
3966+
check(expected, changes, fileMetadataTable, "fake-server", FAKE_PARENT);
3967+
});
3968+
39363969
test(suiteLabel("one_update_link_special_char"), async () => {
39373970
const changes: ConfluenceSpaceChange[] = [UPDATE_LINKS_SPECIAL_CHAR];
39383971
const rootURL = "fake-server/wiki/spaces/QUARTOCONF/pages";

0 commit comments

Comments
 (0)