Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add GFM support #29

Merged
merged 2 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 45 additions & 48 deletions gatsby-config.js → gatsby-config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable */
import remarkGfm from "remark-gfm";

module.exports = ({
contentAuthors = 'content/authors',
contentPosts = 'content/posts',
pathPrefix = '',
export default ({
contentAuthors = "content/authors",
contentPosts = "content/posts",
pathPrefix = ""
}) => ({
pathPrefix,
plugins: [
Expand Down Expand Up @@ -33,20 +34,19 @@ module.exports = ({
`,
setup: ({
query: {
site: { siteMetadata },
site: { siteMetadata }
},
...rest
}) => {
siteMetadata.feed_url = siteMetadata.siteUrl + '/rss.xml';
siteMetadata.image_url =
siteMetadata.siteUrl + '/icons/icon-512x512.png';
siteMetadata.feed_url = `${siteMetadata.siteUrl}/rss.xml`;
siteMetadata.image_url = `${siteMetadata.siteUrl}/icons/icon-512x512.png`;
const siteMetadataModified = siteMetadata;
siteMetadataModified.feed_url = `${siteMetadata.siteUrl}/rss.xml`;
siteMetadataModified.image_url = `${siteMetadata.siteUrl}/icons/icon-512x512.png`;

return {
...siteMetadataModified,
...rest,
...rest
};
},
feeds: [
Expand All @@ -60,16 +60,13 @@ module.exports = ({
...edge.node,
description: edge.node.excerpt,
date: edge.node.date,
url: site.siteMetadata.siteUrl + edge.node.slug,
guid: site.siteMetadata.siteUrl + edge.node.slug,
// body is raw JS and MDX; will need to be processed before it can be used
// custom_elements: [{ "content:encoded": edge.node.body }],
author: edge.node.author,
url: `${site.siteMetadata.siteUrl}${edge.node.slug}`,
guid: `${site.siteMetadata.siteUrl}${edge.node.slug}`,
author: edge.node.author
};
});
},
query:
`{
query: `{
allArticle(sort: {date: DESC}) {
edges {
node {
Expand All @@ -84,24 +81,24 @@ module.exports = ({
}
}
}`,
output: '/rss.xml',
},
],
},
output: "/rss.xml"
}
]
}
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: contentPosts,
name: contentPosts,
},
name: contentPosts
}
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: contentAuthors,
name: contentAuthors,
},
name: contentAuthors
}
},
{
resolve: `gatsby-plugin-mdx`,
Expand All @@ -114,8 +111,8 @@ module.exports = ({
maxWidth: 800,
linkImagesToOriginal: false,
quality: 80,
withWebp: true,
},
withWebp: true
}
},
{
resolve: `@raae/gatsby-remark-oembed`,
Expand All @@ -130,47 +127,47 @@ module.exports = ({
resolve: "gatsby-remark-embed-video",
options: {
width: 680,
ratio: 1.77, // Optional: Defaults to 16/9 = 1.77
height: 400, // Optional: Overrides optional.ratio
related: false, //Optional: Will remove related videos from the end of an embedded YouTube video.
noIframeBorder: true, //Optional: Disable insertion of <style> border: 0
ratio: 1.77,
height: 400,
related: false,
noIframeBorder: true,
urlOverrides: [
{
id: 'youtube',
embedURL: (videoId) => `https://www.youtube-nocookie.com/embed/${videoId}`,
id: "youtube",
embedURL: videoId =>
`https://www.youtube-nocookie.com/embed/${videoId}`
}
] //Optional: Override URL of a service provider, e.g to enable youtube-nocookie support
]
}
},
{ resolve: `gatsby-remark-copy-linked-files` },
{ resolve: `gatsby-remark-numbered-footnotes` },
{ resolve: `gatsby-remark-smartypants` },
{
resolve: 'gatsby-remark-external-links',
resolve: "gatsby-remark-external-links",
options: {
target: '_blank',
rel: 'noreferrer', // eslint-disable-line unicorn/prevent-abbreviations
},
target: "_blank",
rel: "noreferrer"
}
},
{
resolve: `@sudaraka94/gatsby-remark-link-unfurl`,
options: {
processedUrlsFile: `${__dirname}/link-cache/cache.json`,
},
},
processedUrlsFile: `${process.cwd()}/link-cache/cache.json`
}
}
],
mdxOptions: {
rehypePlugins: [
{ resolve: "rehype-slug" }
]
remarkPlugins: [remarkGfm],
rehypePlugins: [{ resolve: "rehype-slug" }]
}
},
}
},
{
resolve: `gatsby-plugin-emotion`,
options: {
autoLabel: 'dev-only',
},
},
],
autoLabel: "dev-only"
}
}
]
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"react-outside-click-handler": "^1.3.0",
"reading-time": "^1.5.0",
"rehype-slug": "^6.0.0",
"remark-gfm": "^3.0.1",
"request": "^2.88.2",
"slugify": "^1.6.6",
"theme-ui": "^0.16.2",
Expand Down
Loading