Skip to content

Commit

Permalink
Merge pull request #11966 from ethereum/staging
Browse files Browse the repository at this point in the history
Staging -> dev
  • Loading branch information
corwintines authored Jan 18, 2024
2 parents 8369921 + 6a16f6e commit 9f6c4d4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
11 changes: 8 additions & 3 deletions src/components/PageMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ const PageMetadata: React.FC<IProps> = ({
const path = asPath.replace(/[\?\#].*/, "")
const slug = path.split("/")

/* Set canonical URL w/ language path to avoid duplicate content */
/* e.g. set ethereum.org/about/ to ethereum.org/en/about/ */
const url = new URL(join(locale === DEFAULT_LOCALE ? "" : locale!, path), SITE_URL).href
/**
* Set canonical URL w/ language path to avoid duplicate content
* If English, remove language path
* Remove trailing slash
* @example ethereum.org/about/ -> ethereum.org/about
* @example ethereum.org/pt-br/web3/ -> ethereum.org/pt-br/web3
*/
const url = new URL(join(locale === DEFAULT_LOCALE ? "" : locale!, path), SITE_URL).href.replace(/\/$/, "")
const canonical = canonicalUrl || url

/* Set fallback ogImage based on path */
Expand Down
6 changes: 4 additions & 2 deletions src/layouts/Docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ import TableOfContents from "@/components/TableOfContents"
import Translation from "@/components/Translation"
import YouTube from "@/components/YouTube"

import { getEditPath } from "@/lib/utils/editPath"

// Utils
import { DEFAULT_LOCALE, EDIT_CONTENT_URL } from "@/lib/constants"
import { DEFAULT_LOCALE } from "@/lib/constants"

import { useClientSideGitHubLastEdit } from "@/hooks/useClientSideGitHubLastEdit"

Expand Down Expand Up @@ -220,7 +222,7 @@ export const DocsLayout = ({
}: DocsLayoutProps) => {
const isPageIncomplete = !!frontmatter.incomplete
const { asPath: relativePath } = useRouter()
const absoluteEditPath = `${EDIT_CONTENT_URL}${relativePath}`
const absoluteEditPath = getEditPath(relativePath)

const gitHubLastEdit = useClientSideGitHubLastEdit(relativePath)
const intlLastEdit = "data" in gitHubLastEdit ? gitHubLastEdit.data! : ""
Expand Down
8 changes: 2 additions & 6 deletions src/layouts/Static.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ import Translation from "@/components/Translation"
import TranslationChartImage from "@/components/TranslationChartImage"
import UpcomingEventsList from "@/components/UpcomingEventsList"

import { getEditPath } from "@/lib/utils/editPath"
import { getLocaleTimestamp } from "@/lib/utils/time"
import { isLangRightToLeft } from "@/lib/utils/translations"

import { CONTENT_DIR } from "@/lib/constants"

import GuideHeroImage from "@/public/heroes/guides-hub-hero.jpg"

const Heading1 = (props: HeadingProps) => (
Expand Down Expand Up @@ -91,10 +90,7 @@ export const StaticLayout: React.FC<IProps> = ({
}) => {
const { locale } = useRouter()

const repo =
process.env.NEXT_PUBLIC_GITHUB_REPO || "ethereum/ethereum-org-website"
const baseEditPath = `https://github.com/${repo}/tree/dev/${CONTENT_DIR}/`
const absoluteEditPath = baseEditPath + slug + "index.md"
const absoluteEditPath = getEditPath(slug)

return (
<Box w="full">
Expand Down
8 changes: 5 additions & 3 deletions src/layouts/Tutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ import {
Heading4 as MdHeading4,
} from "@/components/MdComponents"
import MdLink from "@/components/MdLink"
import PageMetadata from "@/components/PageMetadata"
import { mdxTableComponents } from "@/components/Table"
import TableOfContents from "@/components/TableOfContents"
import TutorialMetadata from "@/components/TutorialMetadata"
import YouTube from "@/components/YouTube"

import { DEFAULT_LOCALE, EDIT_CONTENT_URL } from "@/lib/constants"
import { getEditPath } from "@/lib/utils/editPath"

import { DEFAULT_LOCALE } from "@/lib/constants"

import { useClientSideGitHubLastEdit } from "@/hooks/useClientSideGitHubLastEdit"

Expand Down Expand Up @@ -180,7 +181,8 @@ export const TutorialLayout = ({
crowdinContributors,
}: TutorialLayoutProps) => {
const { asPath: relativePath } = useRouter()
const absoluteEditPath = `${EDIT_CONTENT_URL}${relativePath}`
const absoluteEditPath = getEditPath(relativePath)

const borderColor = useToken("colors", "border")
const postMergeBannerTranslationString =
frontmatter.postMergeBannerTranslation as TranslationKey | null
Expand Down
5 changes: 3 additions & 2 deletions src/layouts/UseCases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import {
} from "@/components/MdComponents"
import TableOfContents from "@/components/TableOfContents"

import { getEditPath } from "@/lib/utils/editPath"
import { getSummaryPoints } from "@/lib/utils/getSummaryPoints"

import { EDIT_CONTENT_URL, MAIN_CONTENT_ID } from "@/lib/constants"
import { MAIN_CONTENT_ID } from "@/lib/constants"

const HeroContainer = (props: ChildOnlyProp) => (
<Flex
Expand Down Expand Up @@ -94,7 +95,7 @@ export const UseCasesLayout: React.FC<IProps> = ({

const summaryPoints = getSummaryPoints(frontmatter)

const absoluteEditPath = `${EDIT_CONTENT_URL}${relativePath}`
const absoluteEditPath = getEditPath(relativePath)

// Assign hero styling, default to "defi"
let useCase = "defi"
Expand Down
5 changes: 5 additions & 0 deletions src/lib/utils/editPath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { join } from 'path'

import { CONTENT_DIR, EDIT_CONTENT_URL } from '@/lib/constants'

export const getEditPath = (relativePath: string): string => join(EDIT_CONTENT_URL, CONTENT_DIR, relativePath, "index.md")

0 comments on commit 9f6c4d4

Please sign in to comment.