feat: show dev.to posts command

pull/20/head
fegroders 2 years ago
parent 1f2e543bdb
commit b8b81eb5a2

@ -5,7 +5,8 @@
"ascii": "liveterm",
"social": {
"github": "github",
"linkedin": "linkedin"
"linkedin": "linkedin",
"devToUsername": "Dev.to Username"
},
"email": "contact@email.com",
"ps1_hostname": "liveterm",

@ -28,3 +28,10 @@ export const getQuote = async () => {
quote: `${data.content}” — ${data.author}`,
};
};
export const getPostsDevTo = async () => {
const { data } = await axios.get(
`https://dev.to/api/articles?username=${config.social.devToUsername}`,
);
return data;
};

@ -4,6 +4,7 @@ import { getProjects } from '../api';
import { getQuote } from '../api';
import { getReadme } from '../api';
import { getWeather } from '../api';
import { getPostsDevTo } from '../api';
export const projects = async (args: string[]): Promise<string> => {
const projects = await getProjects();
@ -34,3 +35,16 @@ export const weather = async (args: string[]): Promise<string> => {
const weather = await getWeather(city);
return weather;
};
export const posts = async (args: string[]): Promise<string> => {
const posts = await getPostsDevTo();
if (posts.length) {
return `My Latest posts on Dev.To:<br>${posts
.map(
(post) =>
` - <a class="text-light-blue dark:text-dark-blue underline" href="${post.url}" target="_blank">${post.title}</a>`,
).join('\n')}`;
} else {
return `I don't have any posts on Dev.to yet :(`;
}
};
Loading…
Cancel
Save