refactor(starter): upgrade to new version of gatsby

This commit is contained in:
Alexander Shelepenok
2022-01-09 20:12:31 +00:00
parent 84bdc5899d
commit 67ebabbaac
397 changed files with 26665 additions and 34984 deletions

View File

@@ -1,4 +0,0 @@
// @flow strict
export { default as useSiteMetadata } from './use-site-metadata';
export { default as useCategoriesList } from './use-categories-list';
export { default as useTagsList } from './use-tags-list';

3
src/hooks/index.ts Normal file
View File

@@ -0,0 +1,3 @@
export { default as useSiteMetadata } from "./use-site-metadata";
export { default as useCategoriesList } from "./use-categories-list";
export { default as useTagsList } from "./use-tags-list";

View File

@@ -1,23 +0,0 @@
// @flow strict
import { useStaticQuery, graphql } from 'gatsby';
const useCategoriesList = () => {
const { allMarkdownRemark } = useStaticQuery(
graphql`
query CategoriesListQuery {
allMarkdownRemark(
filter: { frontmatter: { template: { eq: "post" }, draft: { ne: true } } }
) {
group(field: frontmatter___category) {
fieldValue
totalCount
}
}
}
`
);
return allMarkdownRemark.group;
};
export default useCategoriesList;

View File

@@ -0,0 +1,33 @@
import { graphql, useStaticQuery } from "gatsby";
interface CategoriesQueryResult {
allMarkdownRemark: {
group: Array<{
fieldValue: string;
totalCount: number;
}>;
};
}
const useCategoriesList = () => {
const { allMarkdownRemark } = useStaticQuery<CategoriesQueryResult>(
graphql`
query CategoriesListQuery {
allMarkdownRemark(
filter: {
frontmatter: { template: { eq: "post" }, draft: { ne: true } }
}
) {
group(field: frontmatter___category) {
fieldValue
totalCount
}
}
}
`,
);
return allMarkdownRemark.group ?? [];
};
export default useCategoriesList;

View File

@@ -1,5 +1,4 @@
// @flow strict
import { useStaticQuery, graphql } from 'gatsby';
import { graphql, useStaticQuery } from "gatsby";
const useSiteMetadata = () => {
const { site } = useStaticQuery(
@@ -8,31 +7,31 @@ const useSiteMetadata = () => {
site {
siteMetadata {
author {
name
bio
name
photo
contacts {
facebook
linkedin
rss
line
email
weibo
gitlab
medium
github
twitter
telegram
instagram
email
rss
vkontakte
line
gitlab
weibo
codepen
youtube
facebook
linkedin
telegram
instagram
vkontakte
soundcloud
medium
}
}
menu {
label
path
label
}
url
title
@@ -42,7 +41,7 @@ const useSiteMetadata = () => {
}
}
}
`
`,
);
return site.siteMetadata;

View File

@@ -1,23 +0,0 @@
// @flow strict
import { useStaticQuery, graphql } from 'gatsby';
const useTagsList = () => {
const { allMarkdownRemark } = useStaticQuery(
graphql`
query TagsListQuery {
allMarkdownRemark(
filter: { frontmatter: { template: { eq: "post" }, draft: { ne: true } } }
) {
group(field: frontmatter___tags) {
fieldValue
totalCount
}
}
}
`
);
return allMarkdownRemark.group;
};
export default useTagsList;

View File

@@ -0,0 +1,33 @@
import { graphql, useStaticQuery } from "gatsby";
interface TagsQueryResult {
allMarkdownRemark: {
group: Array<{
fieldValue: string;
totalCount: number;
}>;
};
}
const useTagsList = () => {
const { allMarkdownRemark } = useStaticQuery<TagsQueryResult>(
graphql`
query TagsListQuery {
allMarkdownRemark(
filter: {
frontmatter: { template: { eq: "post" }, draft: { ne: true } }
}
) {
group(field: frontmatter___tags) {
fieldValue
totalCount
}
}
}>
`,
);
return allMarkdownRemark.group || [];
};
export default useTagsList;