Skip to content

Commit 5a06abb

Browse files
committed
Интеграция типографа
1 parent d9cc3c1 commit 5a06abb

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

gatsby-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,6 @@ module.exports = {
160160
},
161161
'gatsby-plugin-react-helmet',
162162
'gatsby-plugin-catch-links',
163+
'gatsby-remark-typography', // only for Russian translation
163164
],
164165
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"request-promise": "^4.2.2",
5555
"rimraf": "^2.6.1",
5656
"slugify": "^1.2.1",
57+
"typograf": "^6.8.0",
5758
"unist-util-visit": "^1.1.3"
5859
},
5960
"engines": {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const Typograf = require('typograf');
4+
5+
exports.onPreExtractQueries = async ({store, getNodes}) => {
6+
const tp = new Typograf({locale: ['ru']});
7+
const fields = ['title', 'content'];
8+
const markdownNodes = getNodes().filter(node => {
9+
return node.internal.type === 'MarkdownRemark';
10+
});
11+
12+
markdownNodes.forEach(node => {
13+
fields.forEach(field => {
14+
const value = node.frontmatter[field];
15+
16+
if (!value) {
17+
return;
18+
}
19+
20+
node.frontmatter[field] = tp.execute(value);
21+
});
22+
});
23+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "gatsby-remark-typography",
3+
"version": "0.0.1"
4+
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12229,6 +12229,11 @@ typedarray@^0.0.6:
1222912229
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1223012230
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
1223112231

12232+
typograf@^6.8.0:
12233+
version "6.8.0"
12234+
resolved "https://registry.yarnpkg.com/typograf/-/typograf-6.8.0.tgz#103447a52c23bd19cfe65b81f4e95d36b71879a3"
12235+
integrity sha512-TsAXy+fDS0g9H6W9CBhnFlvBsRp7Hq5K/fuuBn5X0P86Me9V/YiSTzuXR6TN83AZ0QXyui9o4LLxQFOPmSyxMA==
12236+
1223212237
ua-parser-js@^0.7.18:
1223312238
version "0.7.18"
1223412239
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.18.tgz#a7bfd92f56edfb117083b69e31d2aa8882d4b1ed"

0 commit comments

Comments
 (0)