Skip to content

refactor(v2): merge linkify function used in blog and docs#4391

Closed
armano2 wants to merge 1 commit into
facebook:masterfrom
armano2:feat/linkify
Closed

refactor(v2): merge linkify function used in blog and docs#4391
armano2 wants to merge 1 commit into
facebook:masterfrom
armano2:feat/linkify

Conversation

@armano2

@armano2 armano2 commented Mar 11, 2021

Copy link
Copy Markdown
Contributor

Motivation

This change extract code used for linking in blog and docs, to utils that it can be latter used in other plugins eg. pages

I decided to not refactor to much to ease code review, but i added few TODO that some of properties between docs and blog should be aligned.

if you prefer that properties should be renamed in this PR, I'm going to merge to this one #4402

Support for pages can/should be done in separate PR as its a feature not a refactor

// const options = getOptions(this);
// TODO provide additinal md processing here? like interlinking pages?
// fileString = linkify(fileString)
return callback && callback(null, fileString);

Have you read the Contributing Guidelines on pull requests?

ay

Test Plan

there is no change in functionality and all unit test should pass, linking still should work in docs and in blog,

it can be tested by clicking in one of links in docs, eg.
https://deploy-preview-4391--docusaurus-2.netlify.app/classic/docs/contributing#get-involved

@armano2
armano2 requested review from lex111 and slorber as code owners March 11, 2021 07:55
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 11, 2021
@netlify

netlify Bot commented Mar 11, 2021

Copy link
Copy Markdown

Comment on lines +40 to +51
{
siteDir: options.siteDir,
sourceToPermalink: options.sourceToPermalink,
onBrokenMarkdownLink(brokenMarkdownLink) {
options.onBrokenMarkdownLink({
// TODO: refactor version to contentPaths
version,
filePath: brokenMarkdownLink.filePath,
link: brokenMarkdownLink.link,
});
},
},

@armano2 armano2 Mar 11, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we rename params docsDirPath, docsDirPathLocalized and property version we can change this block to options

Comment on lines +35 to +39
{
// TODO: refactor names and we can pass version here
contentPath: version.docsDirPath,
contentPathLocalized: version.docsDirPathLocalized,
},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we rename docsDirPath, docsDirPathLocalized we can simply pass here version

Comment on lines +273 to +281
onBrokenMarkdownLink(data) {
onBrokenMarkdownLink({
// TODO: we should return here all contentPaths as we are checking them anyway
// TODO temporary, should consider the file being in localized folder!
folderPath: data.contentPaths.contentPath,
filePath: data.filePath,
link: data.link,
});
},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO temporary, should consider the file being in localized folder!

instead of passing folderPath se should update this code to use contentPaths and we can simply pass onBrokenMarkdownLink function here

@netlify

netlify Bot commented Mar 11, 2021

Copy link
Copy Markdown

Deploy preview for docusaurus-2 ready!

Built without sensitive environment variables with commit 845ff68

https://deploy-preview-4391--docusaurus-2.netlify.app

@github-actions

Copy link
Copy Markdown

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 90
🟢 Accessibility 96
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4391--docusaurus-2.netlify.app/classic/


export type BrokenMarkdownLink<T extends ContentPaths> = {
filePath: string;
contentPaths: T;

@armano2 armano2 Mar 11, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if this name is good enough, docs had version and blog contentPaths, maybe a model is a better name?

@slorber

slorber commented Mar 12, 2021

Copy link
Copy Markdown
Collaborator

Closing in favor of #4402
Thanks

I don't think it's too useful to add support for pages (even for blog, the usefulness is quite limited. Imho it's mostly useful for versioning/docs).
Markdown pages are not the most widely used feature and user can already use absolute paths instead of relative md file paths.
But if you want to add support and it does not complicate too much, go. ahead.

@slorber slorber closed this Mar 12, 2021
@armano2
armano2 deleted the feat/linkify branch March 12, 2021 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants