Expand One Line Links
━━━━━━━━━━━━━━━━━━━━━
I wanted a super simple way to cross-link blog posts that require as little effort as possible, yet still looks good in vanilla markdown in GitHub. I have...
Date: November 18, 2020
I wanted a super simple way to cross-link blog posts that require as little effort as possible, yet still looks good in vanilla markdown in GitHub. I have been using a snippet that puts [4m[38;2;127;187;179mHTML[0m <[38;2;122;132;120m/html/[0m> into the markdown. While this works, it’s more manual/difficult for me does not look the best, and does not read well as
[1m[38;2;167;192;128mGoals for new card[0m
[38;2;71;82;88m──────────────────[0m
The new card should be fully automated to expand with title, description, and cover image. Bonus if I am able to attach a comment behind it.
- fully automated
- card expansion
- Title
- description
- cover image
[1m[38;2;167;192;128mOld Card[0m
[38;2;71;82;88m────────[0m
If you can call it a card 🤣. This card was just an image wrapped in an anchor tag and a paragraph tag. I found this was the most consistent way to get an image narrower and centered in both GitHub and dev.to.
[38;2;122;132;120m[code][0m
[4m[38;2;127;187;179mImage: My first eight years as a working professional article [0m <[38;2;122;132;120mhttps://waylonwalker.com/notes/eight-years-cat[0m>
The key here is that I have to put the HTML into the markdown. It looks a bit dirty while editing and quite frankly it’s a pain to deal with.
[38;2;71;82;88m--------[0m
[1m[38;2;167;192;128mNew Card[0m
[38;2;71;82;88m────────[0m
[38;2;122;132;120m[code][0m
My first eight years as a working professional.
This day 8 years ago I started my first day as a Mechanical Engineer. I am so grateful for this journey that I have been able to have. There is no way that I could have planned this journey from the beginning.
read more waylonwalker.com
[4m[38;2;127;187;179mMy first eight years as a working professional.[0m <[38;2;122;132;120m/eight-years-cat/[0m>
[1m[38;2;167;192;128mFirst step[0m
[38;2;71;82;88m──────────[0m
My first attempt was to make my own transformer for [38;2;167;192;128mgatsby-remark-embedder[0m. I previously set this up on my site for Twitter and YouTube. I tried to get some custom transformers going, to do what I wanted for my own website, but failed. I really struggled to understand what data was coming in and out of the transformer. My lack of js/node debugging skills was really showing.
[4m[38;2;127;187;179mgatsby-remark-embedder[0m <[38;2;122;132;120m/gatsby-remark-embedder/[0m>
[38;2;122;132;120m│ [0musing gatsby-remark-embedder to expand Twitter/YouTube
[1m[38;2;167;192;128mRedirects[0m
[38;2;71;82;88m─────────[0m
It also works with redirects. I have a redirect to my “latest” post. It’s something that I don’t do the best job at keeping up to date, but when I feel really proud of a post I make it the latest.
[4m[38;2;127;187;179mlatest[0m <[38;2;122;132;120m/latest/[0m>
[38;2;122;132;120m│ [0mthis post is a redirect to my “latest post”
[1m[38;2;167;192;128mClient Side[0m
[38;2;71;82;88m───────────[0m
I started out by running this card expansion client side. This was the strategy that I used to find the list of elements that should be transformed.
- get all anchors
- get all paragraphs
- filter paragraphs where the content is one of the links
- filter paragraphs where there is only one element in the paragraph
- filter to paragraphs with links that
shouldTransform
- These elements should have the
oneLineLinkCard
applied.
[38;2;122;132;120m[code][0m
[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180moneLineLinks[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m([0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180m{[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180mlinkText[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m[[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;214;203;180mdocument[0m[38;2;122;132;120m.[0m[38;2;214;203;180mquerySelectorAll[0m[38;2;214;203;180m([0m[38;2;178;201;143m'[0m[38;2;178;201;143m.post-body p a[0m[38;2;178;201;143m'[0m[38;2;214;203;180m)[0m[38;2;214;203;180m][0m[38;2;122;132;120m.[0m[38;2;214;203;180mmap[0m[38;2;214;203;180m([0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m([0m[38;2;214;203;180mp[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mp[0m[38;2;122;132;120m.[0m[38;2;214;203;180minnerText[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180mparagraphs[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180mdocument[0m[38;2;122;132;120m.[0m[38;2;214;203;180mquerySelectorAll[0m[38;2;214;203;180m([0m[38;2;178;201;143m'[0m[38;2;178;201;143m.post-body p[0m[38;2;178;201;143m'[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m/[0m[38;2;122;132;120m/[0m[38;2;214;203;180m[0m
[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180mregex[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;122;132;120m/[0m[38;2;122;132;120m^[0m[38;2;214;203;180mhttps[0m[38;2;214;203;180m?[0m[38;2;214;203;180m:[0m[38;2;214;203;180m\[0m[38;2;122;132;120m/[0m[38;2;214;203;180m\[0m[38;2;122;132;120m/[0m[38;2;214;203;180mwaylonwalker[0m[38;2;214;203;180m\[0m[38;2;122;132;120m.[0m[38;2;214;203;180mcom[0m[38;2;214;203;180m\[0m[38;2;122;132;120m/[0m[38;2;122;132;120m/[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180mshouldTransform[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m([0m[38;2;214;203;180murl[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mregex[0m[38;2;122;132;120m.[0m[38;2;214;203;180mtest[0m[38;2;214;203;180m([0m[38;2;214;203;180murl[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180manchorOnly[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m[[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;214;203;180mparagraphs[0m[38;2;214;203;180m][0m[38;2;122;132;120m.[0m[38;2;214;203;180mfilter[0m[38;2;214;203;180m([0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m([0m[38;2;214;203;180mp[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mlinkText[0m[38;2;122;132;120m.[0m[38;2;214;203;180mincludes[0m[38;2;214;203;180m([0m[38;2;214;203;180mp[0m[38;2;122;132;120m.[0m[38;2;214;203;180minnerText[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m&&[0m[38;2;214;203;180m [0m[38;2;214;203;180mp[0m[38;2;122;132;120m.[0m[38;2;214;203;180mchildElementCount[0m[38;2;214;203;180m [0m[38;2;122;132;120m==[0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;153;182m1[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180manchorOnly[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m.[0m[38;2;214;203;180mfilter[0m[38;2;214;203;180m([0m[38;2;214;203;180m([0m[38;2;214;203;180mp[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mshouldTransform[0m[38;2;214;203;180m([0m[38;2;214;203;180mp[0m[38;2;122;132;120m.[0m[38;2;214;203;180mfirstElementChild[0m[38;2;122;132;120m.[0m[38;2;214;203;180mhref[0m[38;2;214;203;180m)[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m.[0m[38;2;214;203;180mmap[0m[38;2;214;203;180m([0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180masync[0m[38;2;214;203;180m [0m[38;2;214;203;180m([0m[38;2;214;203;180mp[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m([0m[38;2;214;203;180mp[0m[38;2;122;132;120m.[0m[38;2;214;203;180mouterHTML[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180mawait[0m[38;2;214;203;180m [0m[38;2;214;203;180moneLineLinkCard[0m[38;2;214;203;180m([0m[38;2;214;203;180mp[0m[38;2;122;132;120m.[0m[38;2;214;203;180mfirstElementChild[0m[38;2;122;132;120m.[0m[38;2;214;203;180mhref[0m[38;2;214;203;180m)[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m}[0m
[1m[38;2;167;192;128mStyles[0m
[38;2;71;82;88m──────[0m
CSS is not my strong suit, but I can generally hammer something into a shape that I am happy with. For this one, I did struggle a bit with how it looked on various screens, particularly because I was holding the cover image size to a hard 300px. I ended up with more media queries than I needed, but it works.
[38;2;122;132;120m[code][0m
.onelinelink + blockquote {
position: relative;
left: 2rem;
background: rgba(0, 0, 0, .2);
margin: -6rem auto 1rem;
padding-top: 3rem;
border: 1px solid goldenrod;
border-top: 2px solid goldenrod;
max-width: 300px;
@media (max-width: 350px) {
left: 0rem;
margin-left: .4rem;
margin-right: .4rem;
}
@media (min-width: 800px) {
max-width: 600px;
}
@media (min-width: 900px) {
max-width: 700px;
}
@media (min-width: 1000px) {
max-width: 800px;
}
border-radius: 15px/45px;
display: block;
}
}
.onelinelink {
position: relative;
z-index: 2;
margin: 4rem;
overflow: hidden;
display: flex;
border: 2px solid rgba(255, 50, 50, .1);
background: rgba(255, 50, 50, .015);
background: #262236;
text-decoration: none;
border-radius: 8px;
max-height: 126px;
@media (max-width: 800px) {
flex-direction: column;
max-height: 800px;
max-width: 300px;
margin: 4rem auto;
}
h2 {
top: -1.2rem;
postition: relative;
margin: 0;
padding: 0;
font-size: .8rem;
font-weight: 400;
}
.right {
width: 100%;
padding: 5px 15px;
}
.description {
font-size: 1rem;
line-height: 1.2rem;
height: calc(100% - 31px - 1rem);
padding: 0;
padding-bottom: 1rem;
padding-top: .1rem;
margin: 0;
}
.url {
padding-right: 30px;
color: rgba(255, 255, 255, .1);
text-align: right;
position: relative;
z-index: 2;
background: #262236;
}
img {
max-width: 300px;
max-height: 126px;
padding: 0;
margin: 0;
border-radius: 8px 0 0 8px;
}
.read-more {
font-size: .6rem;
color: rgba(255, 255, 255, .08);
}
}
[1m[38;2;167;192;128m### Final Look[0m
On mobile, it renders vertically.
Image: mobile
On desktop, it renders horizontally.
Image: desktop
[1m[38;2;167;192;128mExpansion[0m
[38;2;71;82;88m─────────[0m
I’m sure that all of this can be better, my js skills are still forming. It’s quite humbling to see how hard it is to think in an unfamiliar language. The following [38;2;167;192;128moneLineLineCard[0m renders a string template literal from a paragraph with a single anchor to a card that contains some of that pages meta information. The getDescription` function uses a fetch to get the metadata right from the content of the page.
[38;2;122;132;120m[code][0m
[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180mgetDescription[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m([0m[38;2;214;203;180murl[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180mfetch[0m[38;2;214;203;180m([0m[38;2;214;203;180murl[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m.[0m[38;2;214;203;180mthen[0m[38;2;214;203;180m([0m[38;2;214;203;180m([0m[38;2;214;203;180mr[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mr[0m[38;2;122;132;120m.[0m[38;2;214;203;180mtext[0m[38;2;214;203;180m([0m[38;2;214;203;180m)[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m.[0m[38;2;214;203;180mthen[0m[38;2;214;203;180m([0m[38;2;214;203;180m([0m[38;2;214;203;180mhtml[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180m{[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180mlet[0m[38;2;214;203;180m [0m[38;2;214;203;180mparser[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180mnew[0m[38;2;214;203;180m [0m[38;2;214;203;180mDOMParser[0m[38;2;214;203;180m([0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180mlet[0m[38;2;214;203;180m [0m[38;2;214;203;180mdoc[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180mparser[0m[38;2;122;132;120m.[0m[38;2;214;203;180mparseFromString[0m[38;2;214;203;180m([0m[38;2;214;203;180mhtml[0m[38;2;214;203;180m,[0m[38;2;214;203;180m [0m[38;2;178;201;143m'[0m[38;2;178;201;143mtext/html[0m[38;2;178;201;143m'[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180mlet[0m[38;2;214;203;180m [0m[38;2;214;203;180mmeta[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180mdoc[0m[38;2;122;132;120m.[0m[38;2;214;203;180mquerySelectorAll[0m[38;2;214;203;180m([0m[38;2;178;201;143m'[0m[38;2;178;201;143mmeta[0m[38;2;178;201;143m'[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180mdescription[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m[[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;214;203;180mmeta[0m[38;2;214;203;180m][0m[38;2;122;132;120m.[0m[38;2;214;203;180mfilter[0m[38;2;214;203;180m([0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m([0m[38;2;214;203;180mm[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mm[0m[38;2;122;132;120m.[0m[38;2;214;203;180mname[0m[38;2;214;203;180m [0m[38;2;122;132;120m==[0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;178;201;143m'[0m[38;2;178;201;143mog:description[0m[38;2;178;201;143m'[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m)[0m[38;2;214;203;180m[[0m[38;2;214;153;182m0[0m[38;2;214;203;180m][0m[38;2;122;132;120m.[0m[38;2;214;203;180mcontent[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180mimage[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m[[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;214;203;180mmeta[0m[38;2;214;203;180m][0m[38;2;122;132;120m.[0m[38;2;214;203;180mfilter[0m[38;2;214;203;180m([0m[38;2;214;203;180m([0m[38;2;214;203;180mm[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mm[0m[38;2;122;132;120m.[0m[38;2;214;203;180mname[0m[38;2;214;203;180m [0m[38;2;122;132;120m==[0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;178;201;143m'[0m[38;2;178;201;143mog:image[0m[38;2;178;201;143m'[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[[0m[38;2;214;153;182m0[0m[38;2;214;203;180m][0m[38;2;214;203;180m?[0m[38;2;122;132;120m.[0m[38;2;214;203;180mcontent[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180msm_image[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m[[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;214;203;180mmeta[0m[38;2;214;203;180m][0m[38;2;122;132;120m.[0m[38;2;214;203;180mfilter[0m[38;2;214;203;180m([0m[38;2;214;203;180m([0m[38;2;214;203;180mm[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mm[0m[38;2;122;132;120m.[0m[38;2;214;203;180mname[0m[38;2;214;203;180m [0m[38;2;122;132;120m==[0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;178;201;143m'[0m[38;2;178;201;143mog:sm_image[0m[38;2;178;201;143m'[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[[0m[38;2;214;153;182m0[0m[38;2;214;203;180m][0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m?[0m[38;2;122;132;120m.[0m[38;2;214;203;180mcontent[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180murl[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m[[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;214;203;180mmeta[0m[38;2;214;203;180m][0m[38;2;122;132;120m.[0m[38;2;214;203;180mfilter[0m[38;2;214;203;180m([0m[38;2;214;203;180m([0m[38;2;214;203;180mm[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mm[0m[38;2;122;132;120m.[0m[38;2;214;203;180mname[0m[38;2;214;203;180m [0m[38;2;122;132;120m==[0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;178;201;143m'[0m[38;2;178;201;143mog:url[0m[38;2;178;201;143m'[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[[0m[38;2;214;153;182m0[0m[38;2;214;203;180m][0m[38;2;214;203;180m?[0m[38;2;122;132;120m.[0m[38;2;214;203;180mcontent[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180mtitle[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m[[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;122;132;120m.[0m[38;2;214;203;180mmeta[0m[38;2;214;203;180m][0m[38;2;122;132;120m.[0m[38;2;214;203;180mfilter[0m[38;2;214;203;180m([0m[38;2;214;203;180m([0m[38;2;214;203;180mm[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mm[0m[38;2;122;132;120m.[0m[38;2;214;203;180mname[0m[38;2;214;203;180m [0m[38;2;122;132;120m==[0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;178;201;143m'[0m[38;2;178;201;143mtitle[0m[38;2;178;201;143m'[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[[0m[38;2;214;153;182m0[0m[38;2;214;203;180m][0m[38;2;214;203;180m?[0m[38;2;122;132;120m.[0m[38;2;214;203;180mcontent[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mreturn[0m[38;2;214;203;180m [0m[38;2;214;203;180m{[0m[38;2;214;203;180m [0m[38;2;214;203;180mdescription[0m[38;2;214;203;180m,[0m[38;2;214;203;180m [0m[38;2;214;203;180mimage[0m[38;2;214;203;180m,[0m[38;2;214;203;180m [0m[38;2;214;203;180murl[0m[38;2;214;203;180m,[0m[38;2;214;203;180m [0m[38;2;214;203;180mtitle[0m[38;2;214;203;180m,[0m[38;2;214;203;180m [0m[38;2;214;203;180msm_image[0m[38;2;214;203;180m [0m[38;2;214;203;180m}[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m}[0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m[0m
[38;2;230;126;128mconst[0m[38;2;214;203;180m [0m[38;2;214;203;180moneLineLinkCard[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;214;203;180m [0m[38;2;214;203;180m([0m[38;2;214;203;180murl[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180m{[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;230;126;128mreturn[0m[38;2;214;203;180m [0m[38;2;214;203;180mgetDescription[0m[38;2;214;203;180m([0m[38;2;214;203;180murl[0m[38;2;214;203;180m)[0m[38;2;122;132;120m.[0m[38;2;214;203;180mthen[0m[38;2;214;203;180m([0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m([0m[38;2;214;203;180mmeta[0m[38;2;214;203;180m)[0m[38;2;214;203;180m [0m[38;2;122;132;120m=[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m`[0m[38;2;122;132;120m<[0m[38;2;214;203;180ma[0m[38;2;214;203;180m [0m[38;2;230;126;128mclass[0m[38;2;122;132;120m=[0m[38;2;178;201;143m"[0m[38;2;178;201;143monelinelink[0m[38;2;178;201;143m"[0m[38;2;214;203;180m [0m[38;2;214;203;180mhref[0m[38;2;122;132;120m=[0m[38;2;122;132;120m$[0m[38;2;214;203;180m{[0m[38;2;214;203;180mmeta[0m[38;2;122;132;120m.[0m[38;2;214;203;180murl[0m[38;2;214;203;180m}[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m<[0m[38;2;214;203;180mimg[0m[38;2;214;203;180m [0m[38;2;214;203;180msrc[0m[38;2;122;132;120m=[0m[38;2;178;201;143m'[0m[38;2;178;201;143m${meta.sm_image ? meta.sm_image : meta.image ? meta.image : [0m[38;2;178;201;143m'[0m[38;2;178;201;143m'[0m[38;2;178;201;143m}[0m[38;2;178;201;143m'[0m[38;2;214;203;180m [0m[38;2;214;203;180malt[0m[38;2;122;132;120m=[0m[38;2;178;201;143m'[0m[38;2;178;201;143mcover image for ${meta.title ? meta.title : [0m[38;2;178;201;143m'[0m[38;2;178;201;143m'[0m[38;2;178;201;143m}>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m<[0m[38;2;214;203;180mdiv[0m[38;2;214;203;180m [0m[38;2;230;126;128mclass[0m[38;2;122;132;120m=[0m[38;2;178;201;143m"[0m[38;2;178;201;143mright[0m[38;2;178;201;143m"[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m<[0m[38;2;214;203;180mh2[0m[38;2;122;132;120m>[0m[38;2;122;132;120m$[0m[38;2;214;203;180m{[0m[38;2;214;203;180mmeta[0m[38;2;122;132;120m.[0m[38;2;214;203;180mtitle[0m[38;2;214;203;180m [0m[38;2;214;203;180m?[0m[38;2;214;203;180m [0m[38;2;214;203;180mmeta[0m[38;2;122;132;120m.[0m[38;2;214;203;180mtitle[0m[38;2;214;203;180m [0m[38;2;214;203;180m:[0m[38;2;214;203;180m [0m[38;2;178;201;143m'[0m[38;2;178;201;143m'[0m[38;2;214;203;180m}[0m[38;2;122;132;120m<[0m[38;2;122;132;120m/[0m[38;2;214;203;180mh2[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m<[0m[38;2;214;203;180mp[0m[38;2;214;203;180m [0m[38;2;230;126;128mclass[0m[38;2;122;132;120m=[0m[38;2;178;201;143m'[0m[38;2;178;201;143mdescription[0m[38;2;178;201;143m'[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m$[0m[38;2;214;203;180m{[0m[38;2;214;203;180mmeta[0m[38;2;122;132;120m.[0m[38;2;214;203;180mdescription[0m[38;2;214;203;180m [0m[38;2;214;203;180m?[0m[38;2;214;203;180m [0m[38;2;214;203;180mmeta[0m[38;2;122;132;120m.[0m[38;2;214;203;180mdescription[0m[38;2;214;203;180m [0m[38;2;214;203;180m:[0m[38;2;214;203;180m [0m[38;2;178;201;143m'[0m[38;2;178;201;143m'[0m[38;2;214;203;180m}[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m<[0m[38;2;122;132;120m/[0m[38;2;214;203;180mp[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m<[0m[38;2;214;203;180mp[0m[38;2;214;203;180m [0m[38;2;230;126;128mclass[0m[38;2;122;132;120m=[0m[38;2;178;201;143m"[0m[38;2;178;201;143murl[0m[38;2;178;201;143m"[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m<[0m[38;2;214;203;180mspan[0m[38;2;214;203;180m [0m[38;2;230;126;128mclass[0m[38;2;122;132;120m=[0m[38;2;178;201;143m'[0m[38;2;178;201;143mread-more[0m[38;2;178;201;143m'[0m[38;2;122;132;120m>[0m[38;2;214;203;180mread[0m[38;2;214;203;180m [0m[38;2;214;203;180mmore[0m[38;2;122;132;120m<[0m[38;2;122;132;120m/[0m[38;2;214;203;180mspan[0m[38;2;122;132;120m>[0m[38;2;214;203;180m [0m[38;2;214;203;180mwaylonwalker[0m[38;2;122;132;120m.[0m[38;2;214;203;180mcom[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m<[0m[38;2;122;132;120m/[0m[38;2;214;203;180mp[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;122;132;120m<[0m[38;2;122;132;120m/[0m[38;2;214;203;180mdiv[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m[0m
[38;2;122;132;120m<[0m[38;2;122;132;120m/[0m[38;2;214;203;180ma[0m[38;2;122;132;120m>[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m`[0m[38;2;214;203;180m[0m
[38;2;214;203;180m [0m[38;2;214;203;180m)[0m[38;2;214;203;180m[0m
[38;2;214;203;180m}[0m
[1m[38;2;167;192;128mIt works[0m
[38;2;71;82;88m────────[0m
And it works. Whenever I reference my own blog with just a single link on a line in markdown I get a nice card link out to the other post, with a small image sized for the card, the title, and the description of the post.
[1m[38;2;167;192;128mBut[0m
[38;2;71;82;88m───[0m
- too much client-side
- does not work well with cross-posting
For every link I do this with the client will pull the full page just to get a bit of metadata. I am already doing a bit more than I want to do client-side for a blog, so I would prefer to do it ahead of time.
Additionally, since it is done client-side it does not translate well when I copy my markdown to various other blogging platforms. If it were rendered right into the markdown cross-posting would be much easier.
[1m[38;2;167;192;128mFuture State[0m
[38;2;71;82;88m────────────[0m
[3mactually already implemented at this point[0m
The direction I am going to try is to use python to load each post, look for lines that contain only a link, then render this same markup right in the markdown. For this I am going to use a language I am more familiar with, python, and do this inside of GitHub actions just before build time so that the markdown I write stays the same, the cards will only be rendered in prod.
[1m[38;2;167;192;128mWhy Python 🐍[0m
[38;2;71;82;88m────────────[0m
Python is my every day what I know, I work much more efficiently and cleanly with it. Also the more I blog the more abstractions I am seeing and the lazier I am getting. Things like description, SEO, cover images are all getting automated. Gatsby really doesn’t like to run when some of those things are missing, probably due to my lack of JS error handling skills. I find it much easier to load up all the pages and patch up the frontmatter in python before build time.
I am kinda curious if eventually, I can re-create everything I need in python because I am honestly not using react for much more than a glorified templating system, besides search. If I can pre-render everything in python
[1m[38;2;167;192;128mWhat do you think??[0m
[38;2;71;82;88m───────────────────[0m
Do they look good? Could they be better?