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

enchane(sync): add wikilink config opts for gdoc export #3209

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
17 changes: 15 additions & 2 deletions packages/engine-server/src/markdown/remark/dendronPub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type PluginOpts = NoteRefsOptsV2 & {
transformNoPublish?: boolean;
/** Don't display randomly generated colors for tags, only display color if it's explicitly set by the user. */
noRandomlyColoredTags?: boolean;
wikiLinkToURL?: boolean;
};

/**
Expand Down Expand Up @@ -359,13 +360,25 @@ function plugin(this: Unified.Processor, opts?: PluginOpts): Transformer {
}
}
const alias = data.alias ? data.alias : value;
const href = SiteUtils.getSiteUrlPathForNote({
addPrefix: pOpts.flavor === ProcFlavor.PUBLISHING,
let href = SiteUtils.getSiteUrlPathForNote({
addPrefix:
pOpts.flavor === ProcFlavor.PUBLISHING || opts?.wikiLinkToURL,
pathValue: value,
config,
pathAnchor: data.anchorHeader,
note,
});
// wikiLinkToURL implies full site path
if (opts?.wikiLinkToURL) {
const { url: root, index } = SiteUtils.getSiteUrlRootForVault({
vault,
config,
});
if (_.isUndefined(root)) {
throw new DendronError({ message: "siteUrl not set" });
}
href = href === "/" ? root : [root, href].join("");
}
const exists = true;
// for rehype
//_node.value = newValue;
Expand Down
1 change: 1 addition & 0 deletions packages/engine-server/src/markdown/utilsv5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export class MDUtilsV5 {
proc = proc.use(dendronPub, {
insertTitle,
transformNoPublish: opts.flavor === ProcFlavor.PUBLISHING,
wikiLinkToURL: true,
...data.publishOpts,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class GoogleDocsExportPodCommand extends BaseExportPodCommand<
exportScope,
accessToken,
refreshToken,
wikiLinkToURL: opts?.wikiLinkToURL || false,
...opts,
podType: PodV2Types.GoogleDocsExportV2,
expirationTime,
Expand Down
9 changes: 8 additions & 1 deletion packages/pods-core/src/v2/podConfig/GoogleDocsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { ExportPodConfigurationV2 } from "./PodV2Types";
/**
* Complete Pod Config for Google Docs V2
*/
export type GoogleDocsV2PodConfig = ExportPodConfigurationV2;
export type GoogleDocsV2PodConfig = ExportPodConfigurationV2 & {
wikiLinkToURL?: boolean;
};
/**
* This is the persisted version of the config that gets serialized into a YAML
* file. It must contain a reference to a google service connection ID.
Expand Down Expand Up @@ -75,6 +77,11 @@ export function createRunnableGoogleDocsV2PodConfigSchema(): JSONSchemaType<Runn
type: "string",
nullable: true,
},
wikiLinkToURL: {
type: "boolean",
default: false,
nullable: true,
},
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class GoogleDocsExportPodV2
fname: input.fname,
vaultName: input.vault,
dest: "stdout",
convertLinks: false,
convertLinks: this._config.wikiLinkToURL,
};
// converts markdown to html using HTMLPublish pod. The Drive API supports converting MIME types while creating a file.
let data = await pod.plant({
Expand Down Expand Up @@ -327,6 +327,12 @@ export class GoogleDocsExportPodV2
description: "ID of the Airtable Connected Service",
type: "string",
},
wikiLinkToURL: {
description: "How to convert the wikilinks",
type: "boolean",
default: false,
nullable: true,
},
},
}) as JSONSchemaType<GoogleDocsV2PodConfig>;
}
Expand Down