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

支持外链转换 #790

Closed
terwer opened this issue Oct 12, 2023 · 3 comments
Closed

支持外链转换 #790

terwer opened this issue Oct 12, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@terwer
Copy link
Owner

terwer commented Oct 12, 2023

image

@terwer terwer added the enhancement New feature or request label Oct 12, 2023
@terwer terwer self-assigned this Oct 12, 2023
@terwer
Copy link
Owner Author

terwer commented Oct 28, 2023

注意:必须设置->导出->引用->锚文本块链。

@terwer
Copy link
Owner Author

terwer commented Oct 28, 2023

const text = `
哈哈哈哈

看看[[001.测试正式文章1](siyuan://blocks/20231028124327-so12rua)](siyuan://blocks/20231028124327-so12rua)

[[001.测试正式文章1](siyuan://blocks/20231028124327-so12rua)](siyuan://blocks/20231028124327-so12rua)



[[001.测试正式文章1](siyuan://blocks/20231028124327-so12rua)](siyuan://blocks/20231028124327-so12rua)



[[测试无数字](siyuan://blocks/20231028124327-so12rua)](siyuan://blocks/20231028124327-so12rua)
`;

const regex = /\[(\d+\..*?|\D+?)\]\(siyuan:\/\/blocks\/(\d+-\w+)\)/g;

const replacedText = text.replace(regex, (match, title, id) => {
  const processedTitle = title.replace(/^\d+\./, ''); // 去除数字和点
  return `[${processedTitle}](/post/${id}.html)`;
});

console.log(replacedText);

terwer added a commit that referenced this issue Oct 29, 2023
@terwer terwer changed the title Vuepress 支持外链转换 支持外链转换 Oct 29, 2023
@terwer
Copy link
Owner Author

terwer commented Oct 29, 2023

外链平台测试

  • 语雀
  • Notion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant