gladevise / remark-link-card Goto Github PK
View Code? Open in Web Editor NEWHome Page: remark-link-card-gladevise.vercel.app
License: MIT License
Home Page: remark-link-card-gladevise.vercel.app
License: MIT License
Hi there, I'm just wondering if you have any suggestions for me. Your plugin is crazy awesome. I have one request to make this great plugin better. I would like an option to automatically add target="_blank" to the a tag.
When using remark-link-card and remark-embedder together, the remark-link-card is always applied regardless of the order of the remark plugins.
const remark = require('remark')
const remarkHtmll = require('remark-html')
const { default: remarkEmbdder } = require('@remark-embedder/core')
const rlc = require('remark-link-card')
const CodeSandboxTransformer = {
name: 'CodeSandbox',
// shouldTransform can also be async
shouldTransform(url) {
const { host, pathname } = new URL(url)
return (
['codesandbox.io', 'www.codesandbox.io'].includes(host) &&
pathname.includes('/s/')
)
},
// getHTML can also be async
getHTML(url) {
const iframeUrl = url.replace('/s/', '/embed/')
return `<iframe src="${iframeUrl}" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe>`
},
}
const exampleMarkdown = `
This is a CodeSandbox:
https://codesandbox.io/s/css-variables-vs-themeprovider-df90h
https://www.npmjs.com/package/remark-link-card
`
( async () => {
const result = await remark()
.use(remarkEmbdder, {
transformers: [CodeSandboxTransformer]
})
.use(rlc)
.use(remarkHtmll)
.process(exampleMarkdown)
console.log(result.contents);
})()
<p>This is a CodeSandbox:</p>
<iframe src="https://codesandbox.io/embed/css-variables-vs-themeprovider-df90h" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe>
<a class="rlc-container" href="https://www.npmjs.com/package/remark-link-card">
<div class="rlc-info">
<div class="rlc-title">remark-link-card</div>
<div class="rlc-description">Remark plugin to convert text links to link cards inspired by gatsby-remark-link-card</div>
<div class="rlc-url-container">
<img class="rlc-favicon" src="https://www.google.com/s2/favicons?domain=www.npmjs.com" alt="remark-link-card favicon" width="16px" height="16px">
<span class="rlc-url">https://www.npmjs.com/package/remark-link-card</span>
</div>
</div>
<div class="rlc-image-container">
<img class="rlc-image" src="https://static.npmjs.com/338e4905a2684ca96e08c7780fc68412.png" alt="remark-link-card" width="100%" height="100%"/>
</div>
</a>
<p>This is a CodeSandbox:</p>
<a class="rlc-container" href="https://codesandbox.io/s/css-variables-vs-themeprovider-df90h">
<div class="rlc-info">
<div class="rlc-title">CSS Variables vs ThemeProvider - CodeSandbox</div>
<div class="rlc-description">https://epicreact.dev/css-variables</div>
<div class="rlc-url-container">
<img class="rlc-favicon" src="https://www.google.com/s2/favicons?domain=codesandbox.io" alt="CSS Variables vs ThemeProvider - CodeSandbox favicon" width="16px" height="16px">
<span class="rlc-url">https://codesandbox.io/s/css-variables-vs-themeprovider-df90h</span>
</div>
</div>
<div class="rlc-image-container">
<img class="rlc-image" src="https://codesandbox.io/api/v1/sandboxes/df90h/screenshot.png" alt="CSS Variables vs ThemeProvider - CodeSandbox" width="100%" height="100%"/>
</div>
</a>
<a class="rlc-container" href="https://www.npmjs.com/package/remark-link-card">
<div class="rlc-info">
<div class="rlc-title">remark-link-card</div>
<div class="rlc-description">Remark plugin to convert text links to link cards inspired by gatsby-remark-link-card</div>
<div class="rlc-url-container">
<img class="rlc-favicon" src="https://www.google.com/s2/favicons?domain=www.npmjs.com" alt="remark-link-card favicon" width="16px" height="16px">
<span class="rlc-url">https://www.npmjs.com/package/remark-link-card</span>
</div>
</div>
<div class="rlc-image-container">
<img class="rlc-image" src="https://static.npmjs.com/338e4905a2684ca96e08c7780fc68412.png" alt="remark-link-card" width="100%" height="100%"/>
</div>
</a>
Although optional chaining is very useful and can make your code more concise, it has the following drawbacks
Warning: validateDOMNesting(...): <div> cannot appear as a descendant of <p>.
is occurred by using next-mdx-remote.
We should generate a link card outside of the paragraph.
Originally, if multiple links are written in a single line, it should not be converted to a link card. However, when I use next-mdx-remote and set up the remark-link-card plugin, the first link is converted and the following links disappear.
This is happening with both rlc-simple
and with-cache
in examples/nextjs-mdx-blog
.
When I used this library on my blog created with the astro.build, it came from fetching favicon.ico.
Failed to load resource: the server responded with a status of 404 ()
As I dug into that error, it seems failed to fetch a favicon.ico
because protocols are mismatched which means the application should fetch favicon.ico
from https://www.funailog.com but wants to fetch from http://www.funailog.com
.
Requested URL: https://t2.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://www.funailog.com&size=16
I'd like to know how to fix this problem using by option if exist.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.