| | import getRedirect from '@/redirects/lib/get-redirect' |
| | import { getPathWithoutLanguage, getPathWithoutVersion } from '@/frame/lib/path-utils' |
| |
|
| | const liquidStartRex = /^{%-?\s*ifversion .+?\s*%}/ |
| | const liquidEndRex = /{%-?\s*endif\s*-?%}$/ |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | function stripLiquid(text: string): string { |
| | if (liquidStartRex.test(text) && liquidEndRex.test(text)) { |
| | return text.replace(liquidStartRex, '').replace(liquidEndRex, '').trim() |
| | } else if (text.includes('{')) { |
| | throw new Error(`Unsupported Liquid in frontmatter link list (${text})`) |
| | } |
| | return text |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | export function checkURL(uri: string, index: number, redirectsContext: any) { |
| | const url = `/en${stripLiquid(uri).split('#')[0]}` |
| | if (!(url in redirectsContext.pages)) { |
| | |
| | |
| | let redirects = getRedirect(url, redirectsContext) |
| | |
| | |
| | if (redirects) { |
| | const withoutVersion = getPathWithoutVersion(redirects) |
| | if (withoutVersion === url) { |
| | |
| | return null |
| | } |
| | redirects = getPathWithoutLanguage(withoutVersion) |
| | } |
| | return { uri, index, redirects } |
| | } |
| | return null |
| | } |
| |
|