Skip to content

Commit 5925909

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

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

.github/scripts/gen-feed.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ for (const {name, isFile} of Deno.readDirSync(`./blog/content`)) {
5050
}
5151

5252
for (const script of JSON.parse(Deno.readTextFileSync(scripthubJson)).scripts) {
53-
const { fullname, description, birthtime, avatar } = script
53+
const { cmd, fullname, description, birthtime, avatar } = script
5454
const url = `https://mash.pkgx.sh/${fullname}`
5555
if (description) rv.push({
56-
type: 'script',
56+
type: 'mash',
5757
time: new Date(birthtime),
58-
description: description.split(". ")?.[0] ?? description,
59-
title: fullname,
58+
description: demarkdown(description.split(". ")?.[0] ?? description),
59+
title: cmd,
6060
image: avatar,
6161
url
6262
})
@@ -65,3 +65,11 @@ for (const script of JSON.parse(Deno.readTextFileSync(scripthubJson)).scripts) {
6565
rv.sort((a, b) => b.time.getTime() - a.time.getTime())
6666

6767
console.log(JSON.stringify(rv))
68+
69+
function demarkdown(input: string) {
70+
return input
71+
.replace(/`([^`]+)`/g, "<code>$1</code>")
72+
.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
73+
.replace(/\*([^*]+)\*/g, "<em>$1</em>")
74+
.replace(/~~([^~]+)~~/g, "<del>$1</del>")
75+
}

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)