Skip to content

Instantly share code, notes, and snippets.

@zacjones93
Created October 27, 2022 19:37
Show Gist options
  • Save zacjones93/4c56e544e59afbff2807f73e0a7aa71b to your computer and use it in GitHub Desktop.
Save zacjones93/4c56e544e59afbff2807f73e0a7aa71b to your computer and use it in GitHub Desktop.
// Name: tana-paste-twitter
// Author: Ian Jones
import "@johnlindquist/kit";
const url = await getActiveTab("Brave");
const months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
export const nth = function (d) {
if (d > 3 && d < 21) return "th";
switch (d % 10) {
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
};
export const formatDate = (dateString) => {
const d = new Date(dateString);
const year = d.getFullYear();
const date = d.getDate();
const month = months[d.getMonth()];
const nthStr = nth(date);
return `${month} ${date}${nthStr}, ${year}`;
};
const summary = await arg("Summarize media");
const author = await arg("Author");
const state = await arg("Media State", [
{ name: "Viewed", value: "viewed" },
{ name: "Unviewed", value: "unviewed" },
]);
await copy(`%%tana%%
- ${summary} #tweet
- Source:: ${url}
- Author:: [[${author}]]
- State:: ${state}
`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment