Skip to content

Commit aef1a7b

Browse files
➕ Add remove-markdown for descriptions
1 parent c60e560 commit aef1a7b

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@staart/site",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"module": "dist/module.js",
55
"main": "dist/index.js",
66
"bin": "./dist/index.js",
@@ -43,6 +43,7 @@
4343
"minimist": "^1.2.0",
4444
"node-cache": "^5.0.0",
4545
"recursive-readdir": "^2.2.2",
46+
"remove-markdown": "^0.3.0",
4647
"sass": "^1.23.1",
4748
"signale": "^1.4.0",
4849
"sitemap": "^5.0.1",
@@ -57,6 +58,7 @@
5758
"@types/minimist": "^1.2.0",
5859
"@types/node": "^12.11.7",
5960
"@types/recursive-readdir": "^2.2.0",
61+
"@types/remove-markdown": "^0.1.1",
6062
"@types/sass": "^1.16.0",
6163
"@types/signale": "^1.2.1",
6264
"@types/yaml": "^1.2.0",

src/generator.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { StaartSiteConfig } from "./interfaces";
2929
import { getLastCommit, getGitHubRepoUrl } from "./github";
3030
import { parse as yaml } from "yaml";
3131
import frontMatter from "front-matter";
32+
import removeMarkdown from "remove-markdown";
3233
import { FrontMatter } from "./interfaces";
3334

3435
export const getTemplate = async () => {
@@ -298,7 +299,16 @@ const generatePage = async (path: string, content: string) => {
298299
"title",
299300
"name"
300301
)) || "Staart Site"}`,
301-
...attributes
302+
...attributes,
303+
description:
304+
path === "index.html"
305+
? await getSiteMeta("description")
306+
: attributes.description
307+
? attributes.description
308+
: removeMarkdown(content).replace(
309+
(await getTitle(content)) || "Staart Site",
310+
""
311+
)
302312
};
303313
for await (const key of Object.keys(data)) {
304314
if (typeof data[key] === "string")

src/interfaces.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ export interface FrontMatter {
4141
title: string;
4242
emoji: string;
4343
seoImage: string;
44+
description: string;
4445
[index: string]: string;
4546
}

yarn.lock

+10
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@
127127
resolved "https://registry.yarnpkg.com/@types/relateurl/-/relateurl-0.2.28.tgz#6bda7db8653fa62643f5ee69e9f69c11a392e3a6"
128128
integrity sha1-a9p9uGU/piZD9e5p6facEaOS46Y=
129129

130+
"@types/remove-markdown@^0.1.1":
131+
version "0.1.1"
132+
resolved "https://registry.yarnpkg.com/@types/remove-markdown/-/remove-markdown-0.1.1.tgz#c79d3000df412526186b2af3808b85bee68bc907"
133+
integrity sha512-SCYOFMHUqyiJU5M0V2gBB6UDdBhPwma34j0vYX0JgWaqp/74ila2Ops1jt5tB/C1UQXVXqK+is61884bITn3LQ==
134+
130135
"@types/sass@^1.16.0":
131136
version "1.16.0"
132137
resolved "https://registry.yarnpkg.com/@types/sass/-/sass-1.16.0.tgz#b41ac1c17fa68ffb57d43e2360486ef526b3d57d"
@@ -4070,6 +4075,11 @@ remove-markdown@^0.2.2:
40704075
resolved "https://registry.yarnpkg.com/remove-markdown/-/remove-markdown-0.2.2.tgz#66b0ceeba9fb77ca9636bb1b0307ce21a32a12a6"
40714076
integrity sha1-ZrDO66n7d8qWNrsbAwfOIaMqEqY=
40724077

4078+
remove-markdown@^0.3.0:
4079+
version "0.3.0"
4080+
resolved "https://registry.yarnpkg.com/remove-markdown/-/remove-markdown-0.3.0.tgz#5e4b667493a93579728f3d52ecc1db9ca505dc98"
4081+
integrity sha1-XktmdJOpNXlyjz1S7MHbnKUF3Jg=
4082+
40734083
remove-trailing-separator@^1.0.1:
40744084
version "1.1.0"
40754085
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"

0 commit comments

Comments
 (0)