Skip to content

Commit

Permalink
fix: xlog post card only for certain host
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jan 14, 2024
1 parent 4327e85 commit 2366057
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/markdown/embed-transformers/XLogPost.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { match } from "path-to-regexp"

import { OUR_DOMAIN } from "~/lib/env"

import type { Transformer } from "../rehype-embed"

function getParamsFromShortsURL(url: URL) {
Expand Down Expand Up @@ -31,7 +33,11 @@ function getParamsFromShortsURL(url: URL) {
export const XLogPostTransformer: Transformer = {
name: "XLogShorts",
shouldTransform(url) {
return !!getParamsFromShortsURL(url)
const { host } = url
return (
(host.includes(`.${OUR_DOMAIN}`) || host === OUR_DOMAIN) &&
!!getParamsFromShortsURL(url)
)
},
getHTML(url) {
const { slug, handle } = getParamsFromShortsURL(url)!
Expand Down

0 comments on commit 2366057

Please sign in to comment.