Skip to content

Commit bfa87e9

Browse files
✨ Add social URL generator
1 parent 9f2f931 commit bfa87e9

File tree

3 files changed

+82
-27
lines changed

3 files changed

+82
-27
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@staart/site",
3-
"version": "1.12.3",
3+
"version": "1.12.4",
44
"module": "dist/module.js",
55
"main": "dist/index.js",
66
"bin": "./dist/index.js",

src/content.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,20 @@ export const getSiteContent = async () => {
117117
});
118118
};
119119

120-
const linkify = (attributes: { [index: string]: string }, key: string) =>
121-
attributes[key]
122-
? `<a href="https://${key}.com/${
120+
const linkify = (attributes: { [index: string]: string }, key: string) => {
121+
const icon = (icons as {
122+
[index: string]: { icon: string; generator?: (username: string) => string };
123+
})[key];
124+
icon.generator =
125+
icon.generator || ((username: string) => `https://${key}.com/${username}`);
126+
return attributes[key]
127+
? `<a href="${icon.generator(
123128
attributes[key]
124-
}" aria-label="${key}" class="no-external">
125-
${(icons as { [index: string]: string })[key]}
129+
)}" aria-label="${key}" class="no-external">
130+
${icon.icon}
126131
</a>\n`
127132
: "";
133+
};
128134

129135
const imageToDataUri = async (url: string) => {
130136
const buffer = await axios.get(

0 commit comments

Comments
 (0)