fixed amp path

This commit is contained in:
Sergey Yarkov 2020-08-17 13:17:58 +03:00
parent 0d79c02440
commit 69a95f70a2
4 changed files with 7 additions and 7 deletions

View File

@ -31,7 +31,7 @@ export const shouldUpdateScroll = ({ routerProps: { location } }) => {
export const wrapPageElement = ({ element, props }) => { export const wrapPageElement = ({ element, props }) => {
const { location: { pathname } } = props const { location: { pathname } } = props
pathname.match(/article\/.*\/amp/) !== null ? props.amp = true : props.amp = false pathname.includes('/amp/article/') && props.pageContext.slug ? props.amp = true : props.amp = false
return <Layout {...props}>{element}</Layout> return <Layout {...props}>{element}</Layout>
} }

View File

@ -148,7 +148,7 @@ module.exports = {
components: ['amp-sidebar', 'amp-accordion', 'amp-form'], components: ['amp-sidebar', 'amp-accordion', 'amp-form'],
excludedPaths: ['/404*', '/'], excludedPaths: ['/404*', '/'],
pathIdentifier: '/amp/', pathIdentifier: '/amp/',
relAmpHtmlPattern: '{{canonicalBaseUrl}}{{pathname}}{{pathIdentifier}}', relAmpHtmlPattern: '{{canonicalBaseUrl}}{{pathIdentifier}}{{pathname}}',
relCanonicalPattern: '{{canonicalBaseUrl}}{{pathname}}/', relCanonicalPattern: '{{canonicalBaseUrl}}{{pathname}}/',
useAmpClientIdApi: false, useAmpClientIdApi: false,
}, },

View File

@ -55,7 +55,7 @@ exports.createPages = async ({ actions, graphql }) => {
}) })
createPage({ createPage({
path: `article/${node.frontmatter.slug}/amp/`, path: `amp/article/${node.frontmatter.slug}/`,
component: articleTemplateAMP, component: articleTemplateAMP,
context: { context: {
slug: node.frontmatter.slug, slug: node.frontmatter.slug,

View File

@ -40,7 +40,7 @@ const OnDark = () => {
} }
export const onRenderBody = ({ pathname, setPreBodyComponents }) => { export const onRenderBody = ({ pathname, setPreBodyComponents }) => {
if (pathname.match(/article\/.*\/amp/) !== null) { if (pathname.includes('/amp/article/')) {
return return
} }
@ -49,7 +49,7 @@ export const onRenderBody = ({ pathname, setPreBodyComponents }) => {
export const wrapPageElement = ({ element, props }) => { export const wrapPageElement = ({ element, props }) => {
const { location: { pathname } } = props const { location: { pathname } } = props
pathname.match(/article\/.*\/amp/) !== null ? props.amp = true : props.amp = false pathname.includes('/amp/article/') && props.pageContext.slug ? props.amp = true : props.amp = false
return <Layout {...props}>{element}</Layout> return <Layout {...props}>{element}</Layout>
} }