Skip to content

Commit

Permalink
optimize images
Browse files Browse the repository at this point in the history
  • Loading branch information
tuan2311 committed Aug 10, 2020
1 parent 08a606b commit c2befd0
Show file tree
Hide file tree
Showing 9 changed files with 517 additions and 22 deletions.
2 changes: 1 addition & 1 deletion blog/2020-08-10-my-first-blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ get(object, 'value.1');

* *list 2*

![](/img/512px-eo_circle_lime_letter-t.svg.png "Test image")
![](/img/beautiful-calla-lily-nice-background-color-70725804.jpg "Test image")
39 changes: 25 additions & 14 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ module.exports = {
);
},
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/static/img`,
name: `images`,
},
},
`gatsby-plugin-netlify-cms`,
{
resolve: `gatsby-plugin-mdx`,
Expand All @@ -27,13 +34,29 @@ module.exports = {
default: require.resolve('./src/templates/PageTemplate.tsx'),
},
gatsbyRemarkPlugins: [
{
resolve: `gatsby-remark-relative-images`,
},
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 1035,
sizeByPixelDensity: true,
maxWidth: 896,
linkImagesToOriginal: false,
},
},
{
resolve: 'gatsby-remark-copy-linked-files',
options: {
destinationDir: 'static/',
},
},
{
resolve: `gatsby-remark-responsive-iframe`,
options: {
wrapperStyle: `margin-bottom: 1.0725rem`,
},
},
`gatsby-remark-external-links`,
],
},
},
Expand All @@ -48,18 +71,6 @@ module.exports = {
`gatsby-plugin-postcss`,
`gatsby-plugin-emotion`,
`gatsby-plugin-react-helmet`,
{
resolve: 'gatsby-plugin-manifest',
options: {
name: 'Schönherz Design Stúdió',
short_name: 'schdesign',
start_url: '/',
background_color: '#3d3d3d',
theme_color: '#f8485e',
display: 'standalone',
icon: 'src/images/favicon.ico',
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
Expand Down
6 changes: 5 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');
const { merge } = require('webpack-merge');
const { createFilePath } = require('gatsby-source-filesystem');
const { fmImagesToRelative } = require('gatsby-remark-relative-images');

exports.onCreateWebpackConfig = ({ actions, getConfig }) => {
let config = getConfig();
Expand Down Expand Up @@ -75,3 +75,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
});
});
};

exports.onCreateNode = ({ node }) => {
fmImagesToRelative(node);
};
Loading

0 comments on commit c2befd0

Please sign in to comment.