feat: add initial add article command
This commit is contained in:
@@ -5,3 +5,28 @@ export function json(content: unknown) {
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
export const isValidUrl = (urlString: string) => {
|
||||
try {
|
||||
return Boolean(new URL(urlString));
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const fixRenderedMarkdown = (content: string) => {
|
||||
return content.replace("***\n", "---")
|
||||
.replace("----------------", "---")
|
||||
.replace("\n---", "---")
|
||||
.replace(/^(date:[^'\n]*)'|'/gm, (match, p1, p2) => {
|
||||
if (p1) {
|
||||
// This is a line starting with date: followed by single quotes
|
||||
return p1.replace(/'/gm, "");
|
||||
} else if (p2) {
|
||||
return "";
|
||||
} else {
|
||||
// This is a line with single quotes, but not starting with date:
|
||||
return match;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user