feat: better layout in a lot of places

This commit is contained in:
2023-08-02 01:58:03 +02:00
parent ff3e7f6667
commit 3cfa2274a8
23 changed files with 208 additions and 110 deletions

View File

@ -2,7 +2,7 @@ import { parseDocument, renderMarkdown } from "@lib/documents.ts";
import { parse } from "yaml";
import { createCrud } from "@lib/crud.ts";
import { stringify } from "https://deno.land/std@0.194.0/yaml/stringify.ts";
import { formatDate } from "@lib/string.ts";
import { extractHashTags, formatDate } from "@lib/string.ts";
import { fixRenderedMarkdown } from "@lib/helpers.ts";
export type Article = {
@ -80,10 +80,9 @@ function parseArticle(original: string, id: string): Article {
}
let content = original.slice(range[0], range[1]);
const tags = [];
for (const [hashtag] of original.matchAll(/\B(\#[a-zA-Z\-]+\b)(?!;)/g)) {
tags.push(hashtag.replace(/\#/g, ""));
content = content.replace(hashtag, "");
const tags = extractHashTags(content);
for (const tag of tags) {
content = content.replace("#" + tag, "");
}
return {

View File

@ -1,12 +1,13 @@
import { parseDocument, renderMarkdown } from "@lib/documents.ts";
import { parse } from "yaml";
import { createCrud } from "@lib/crud.ts";
import { extractHashTags } from "@lib/string.ts";
export type Movie = {
id: string;
name: string;
description: string;
hashtags: string[];
tags: string[];
meta: {
date: Date;
image: string;
@ -52,16 +53,15 @@ export function parseMovie(original: string, id: string): Movie {
}
let description = original.slice(range[0], range[1]);
const hashtags = [];
for (const [hashtag] of original.matchAll(/\B(\#[a-zA-Z]+\b)(?!;)/g)) {
hashtags.push(hashtag.replace(/\#/g, ""));
description = description.replace(hashtag, "");
const tags = extractHashTags(description);
for (const tag of tags) {
description = description.replace("#" + tag, "");
}
return {
id,
name,
hashtags,
tags,
description: renderMarkdown(description),
meta,
};