Skip to content

Commit 0322064

Browse files
committed
adjustments on mash items presentation
1 parent 338018f commit 0322064

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

.github/scripts/gen-feed.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ for (const pkg of JSON.parse(Deno.readTextFileSync(pkgsJson))) {
3131
}
3232

3333
import { extract } from "https://deno.land/std@0.206.0/front_matter/any.ts";
34+
import { describe } from "node:test";
3435

3536
for (const {name, isFile} of Deno.readDirSync(`./blog/content`)) {
3637
if (!isFile || !name.endsWith(".md")) continue
@@ -50,13 +51,13 @@ for (const {name, isFile} of Deno.readDirSync(`./blog/content`)) {
5051
}
5152

5253
for (const script of JSON.parse(Deno.readTextFileSync(scripthubJson)).scripts) {
53-
const { fullname, description, birthtime, avatar } = script
54+
const { cmd, fullname, description, birthtime, avatar } = script
5455
const url = `https://mash.pkgx.sh/${fullname}`
5556
if (description) rv.push({
56-
type: 'script',
57+
type: 'mash',
5758
time: new Date(birthtime),
58-
description: description.split(". ")?.[0] ?? description,
59-
title: fullname,
59+
description: demarkdown(description),
60+
title: cmd,
6061
image: avatar,
6162
url
6263
})
@@ -65,3 +66,11 @@ for (const script of JSON.parse(Deno.readTextFileSync(scripthubJson)).scripts) {
6566
rv.sort((a, b) => b.time.getTime() - a.time.getTime())
6667

6768
console.log(JSON.stringify(rv))
69+
70+
function demarkdown(input: any): string | undefined {
71+
let sentences = input.split('.')
72+
if (sentences.length > 1) {
73+
input = sentences[0] + '.'
74+
}
75+
return input.replaceAll(/\[([^\]]+)\]\([^)]+\)/g, '$1');
76+
}

src/pkgx.dev/HomeFeed.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function FeedItemBox(item: FeedItem) {
184184
const color = (() => {
185185
switch (type) {
186186
case 'blog': return 'secondary'
187-
case 'script': return 'primary'
187+
case 'mash': return 'primary'
188188
}
189189
})()
190190

src/utils/FeedItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
type FeedItem = {
3-
type: 'blog' | 'pkg' |'script' | 'highlight'
3+
type: 'blog' | 'pkg' |'mash' | 'highlight'
44
url: string,
55
title: string,
66
time: Date,

0 commit comments

Comments
 (0)