feat: make author clickable
This commit is contained in:
@@ -17,18 +17,13 @@ export type Article = {
|
||||
date: Date;
|
||||
link: string;
|
||||
thumbnail?: string;
|
||||
average?: string;
|
||||
image?: string;
|
||||
author?: string;
|
||||
rating?: number;
|
||||
};
|
||||
};
|
||||
|
||||
const crud = createCrud<Article>({
|
||||
prefix: "Media/articles/",
|
||||
parse: parseArticle,
|
||||
hasThumbnails: true,
|
||||
});
|
||||
|
||||
function renderArticle(article: Article) {
|
||||
const meta = article.meta;
|
||||
if ("date" in meta) {
|
||||
@@ -100,9 +95,12 @@ function parseArticle(original: string, id: string): Article {
|
||||
};
|
||||
}
|
||||
|
||||
const crud = createCrud<Article>({
|
||||
prefix: "Media/articles/",
|
||||
parse: parseArticle,
|
||||
render: renderArticle,
|
||||
hasThumbnails: true,
|
||||
});
|
||||
export const getAllArticles = crud.readAll;
|
||||
export const getArticle = crud.read;
|
||||
export const createArticle = (article: Article) => {
|
||||
const content = renderArticle(article);
|
||||
return crud.create(article.id, content);
|
||||
};
|
||||
export const createArticle = crud.create;
|
||||
|
@@ -14,6 +14,7 @@ export type Movie = {
|
||||
date: Date;
|
||||
image: string;
|
||||
thumbnail?: string;
|
||||
average?: string;
|
||||
author: string;
|
||||
rating: number;
|
||||
status: "not-seen" | "watch-again" | "finished";
|
||||
@@ -99,12 +100,10 @@ export function parseMovie(original: string, id: string): Movie {
|
||||
const crud = createCrud<Movie>({
|
||||
prefix: "Media/movies/",
|
||||
parse: parseMovie,
|
||||
render: renderMovie,
|
||||
hasThumbnails: true,
|
||||
});
|
||||
|
||||
export const getMovie = crud.read;
|
||||
export const getAllMovies = crud.readAll;
|
||||
export const createMovie = (movie: Movie) => {
|
||||
const content = renderMovie(movie);
|
||||
return crud.create(movie.id, content);
|
||||
};
|
||||
export const createMovie = crud.create;
|
||||
|
@@ -37,6 +37,7 @@ export type Recipe = {
|
||||
rating?: number;
|
||||
portion?: number;
|
||||
author?: string;
|
||||
average?: string;
|
||||
thumbnail?: string;
|
||||
};
|
||||
};
|
||||
|
@@ -16,6 +16,7 @@ export type Series = {
|
||||
image: string;
|
||||
author: string;
|
||||
rating: number;
|
||||
average?: string;
|
||||
thumbnail?: string;
|
||||
status: "not-seen" | "watch-again" | "finished";
|
||||
};
|
||||
@@ -100,25 +101,10 @@ export function parseSeries(original: string, id: string): Series {
|
||||
const crud = createCrud<Series>({
|
||||
prefix: "Media/series/",
|
||||
parse: parseSeries,
|
||||
render: renderSeries,
|
||||
hasThumbnails: true,
|
||||
});
|
||||
|
||||
export const getSeries = (id: string) =>
|
||||
crud.read(id).then(async (serie) => {
|
||||
const imageUrl = serie.meta?.image;
|
||||
if (!imageUrl) return serie;
|
||||
const thumbhash = await getThumbhash({ url: imageUrl });
|
||||
if (!thumbhash) return serie;
|
||||
return {
|
||||
...serie,
|
||||
meta: {
|
||||
...serie.meta,
|
||||
thumbnail: btoa(String.fromCharCode(...thumbhash)),
|
||||
},
|
||||
};
|
||||
});
|
||||
export const getSeries = crud.read;
|
||||
export const getAllSeries = crud.readAll;
|
||||
export const createSeries = (series: Series) => {
|
||||
const content = renderSeries(series);
|
||||
return crud.create(series.id, content);
|
||||
};
|
||||
export const createSeries = crud.create;
|
||||
|
Reference in New Issue
Block a user