Skip to content

Commit

Permalink
➕ Add yaml parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Oct 28, 2019
1 parent ee8015f commit 2dfa51f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@staart/site",
"version": "1.1.13",
"version": "1.1.14",
"module": "dist/module.js",
"main": "dist/index.js",
"bin": "./dist/index.js",
Expand Down Expand Up @@ -45,7 +45,8 @@
"recursive-readdir": "^2.2.2",
"sass": "^1.23.1",
"signale": "^1.4.0",
"sitemap": "^5.0.1"
"sitemap": "^5.0.1",
"yaml": "^1.7.2"
},
"devDependencies": {
"@types/cosmiconfig": "^5.0.3",
Expand All @@ -58,6 +59,7 @@
"@types/recursive-readdir": "^2.2.0",
"@types/sass": "^1.16.0",
"@types/signale": "^1.2.1",
"@types/yaml": "^1.2.0",
"gh-release": "^3.5.0",
"gitmoji-changelog": "^1.1.0",
"husky": "^3.0.9",
Expand Down
1 change: 1 addition & 0 deletions redirects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- /example-1 /example-redirected
14 changes: 13 additions & 1 deletion src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { getConfig } from "./config";
import { SitemapStream, streamToPromise } from "sitemap";
import { StaartSiteConfig } from "./interfaces";
import { getLastCommit, getGitHubRepoUrl } from "./github";
import recursiveReadDir = require("recursive-readdir");
import { parse as yaml } from "yaml";

export const getTemplate = async () => {
const result = await cached<string>("template", async () => {
Expand Down Expand Up @@ -69,6 +69,18 @@ export const getSitemapContent = async () => {
return `# Sitemap`;
};

export const getRedirectsContent: string[] = async () => {
const result = await cached<string>("redirects", async () => {
try {
return (await readFile(
join(await getContentPath(), "..", "redirects.yml")
)).toString();
} catch (error) {}
});
if (result) return parse(result);
return {};
};

const renderScss = (styles: string) =>
new Promise((resolve, reject) => {
scss({ data: styles }, (error, result) => {
Expand Down
24 changes: 24 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
esutils "^2.0.2"
js-tokens "^4.0.0"

"@babel/runtime@^7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.6.3.tgz#935122c74c73d2240cafd32ddb5fc2a6cd35cf1f"
integrity sha512-kq6anf9JGjW8Nt5rYfEuGRaEAaH1mkv3Bbu6rYvLOpPh/RusSJXuKPEAoZ7L7gybZkchE8+NV5g9vKF4AGAtsA==
dependencies:
regenerator-runtime "^0.13.2"

"@blakeembrey/deque@^1.0.3":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@blakeembrey/deque/-/deque-1.0.5.tgz#f4fa17fc5ee18317ec01a763d355782c7b395eaf"
Expand Down Expand Up @@ -148,6 +155,11 @@
dependencies:
source-map "^0.6.1"

"@types/yaml@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/yaml/-/yaml-1.2.0.tgz#4ed577fc4ebbd6b829b28734e56d10c9e6984e09"
integrity sha512-GW8b9qM+ebgW3/zjzPm0I1NxMvLaz/YKT9Ph6tTb+Fkeyzd9yLTvQ6ciQ2MorTRmb/qXmfjMerRpG4LviixaqQ==

JSONStream@^1.3.4:
version "1.3.5"
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0"
Expand Down Expand Up @@ -4020,6 +4032,11 @@ regenerator-runtime@^0.11.0:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==

regenerator-runtime@^0.13.2:
version "0.13.3"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5"
integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==

regex-not@^1.0.0, regex-not@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c"
Expand Down Expand Up @@ -5110,6 +5127,13 @@ yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==

yaml@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.7.2.tgz#f26aabf738590ab61efaca502358e48dc9f348b2"
integrity sha512-qXROVp90sb83XtAoqE8bP9RwAkTTZbugRUTm5YeFCBfNRPEp2YzTeqWiz7m5OORHzEvrA/qcGS8hp/E+MMROYw==
dependencies:
"@babel/runtime" "^7.6.3"

yargs-parser@^11.1.1:
version "11.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4"
Expand Down

0 comments on commit 2dfa51f

Please sign in to comment.