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

[docs] add last modification date to page Footer #29509

Merged
merged 8 commits into from
Jun 17, 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
2 changes: 2 additions & 0 deletions docs/components/DocumentationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function DocumentationPage({
hideFromSearch,
platforms,
hideTOC,
modificationDate,
}: DocPageProps) {
const [isMobileMenuVisible, setMobileMenuVisible] = useState(false);
const { version } = usePageApiVersion();
Expand Down Expand Up @@ -151,6 +152,7 @@ export default function DocumentationPage({
packageName={packageName}
previousPage={previousPage}
nextPage={nextPage}
modificationDate={modificationDate}
/>
</div>
</DocumentationNestedScrollLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function DocumentationElements(props: DocumentationElementsProps)
hideFromSearch={props.meta.hideFromSearch}
packageName={props.meta.packageName}
iconUrl={props.meta.iconUrl}
modificationDate={props.meta.modificationDate}
platforms={props.meta.platforms}>
{props.children}
</DocumentationPage>
Expand Down
6 changes: 4 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"dev": "yarn generate-static-resoures && next dev -p 3002",
"build": "next build",
"export": "yarn generate-static-resoures production && yarn run build && yarn run export-issue-404",
"export-preview": "yarn generate-static-resoures preview && yarn run build && yarn run export-issue-404",
"export": "yarn generate-static-resoures production && yarn append-last-modified-dates && yarn run build && yarn run export-issue-404",
"export-preview": "yarn generate-static-resoures preview && yarn append-last-modified-dates && yarn run build && yarn run export-issue-404",
"export-issue-404": "echo \"🛠 Patching https://github.com/vercel/next.js/issues/16528\"; cp out/404/index.html out/404.html",
"export-server": "http-server out -p 8000",
"test-links": "node node_modules/puppeteer/install.mjs && node --async-stack-traces --unhandled-rejections=strict ./scripts/test-links.js",
Expand All @@ -21,6 +21,7 @@
"permissions-sync-android": "npx scrape-permissions-json@latest components/plugins/permissions/data --android",
"remove-version": "node --unhandled-rejections=strict ./scripts/remove-version.js",
"generate-static-resoures": "rimraf public/static/constants && node --unhandled-rejections=strict ./scripts/generate-static-resources.js",
"append-last-modified-dates": "node --unhandled-rejections=strict ./scripts/append-dates.js",
"postinstall": "node --async-stack-traces --unhandled-rejections=strict ./scripts/copy-latest.js && yarn generate-static-resoures"
},
"resolutions": {
Expand Down Expand Up @@ -71,6 +72,7 @@
"devDependencies": {
"@apidevtools/json-schema-ref-parser": "^11.6.0",
"@emotion/jest": "^11.11.0",
"@expo/spawn-async": "^1.7.2",
"@ocular-d/vale-bin": "^2.29.6",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^1.0.0",
Expand Down
3 changes: 1 addition & 2 deletions docs/pages/build-reference/infrastructure.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
modificationDate: April 8th, 2024
title: Build server infrastructure
sidebar_title: Server infrastructure
maxHeadingDepth: 4
Expand All @@ -8,8 +9,6 @@ description: Learn about the current build server infrastructure when using EAS.
import { Collapsible } from '~/ui/components/Collapsible';
import { BuildResourceList } from '~/ui/components/utils/infrastructure';

> This document was last updated on **April 8th, 2024**.

## Builder IP addresses

Here is the [up-to-date list of builder IP addresses](https://expo.dev/eas-build-worker-ips.txt).
Expand Down
3 changes: 2 additions & 1 deletion docs/pages/technical-specs/expo-sfv-0.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
modificationDate: May 24, 2021
title: Expo Structured Field Values
sidebar_title: Expo Structured Field Values
description: Version 0 • Updated 2021-05-24
description: Version 0
---

Structured Field Values for HTTP, [IETF RFC 8941](https://tools.ietf.org/html/rfc8941), is a proposal to formalize header syntax and facilitate nested data.
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/technical-specs/expo-updates-1.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
modificationDate: March 13, 2023
title: Expo Updates v1
sidebar_title: Expo Updates v1
description: Version 1 • Updated 2023-03-13
description: Version 1
---

## Introduction
Expand Down
40 changes: 40 additions & 0 deletions docs/scripts/append-dates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import spawnAsync from '@expo/spawn-async';
import { readdir, readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';

async function appendModificationDate(dir = './pages') {
try {
const files = await readdir(dir, { recursive: true, withFileTypes: true });

for (const file of files) {
if (!file.isDirectory() && file.name.endsWith('.mdx')) {
const filePath = path.join(file.path, file.name);

const { stdout } = await spawnAsync(
'git',
['log', '-1', '--pretty="%cd"', '--date=format:"%B %d, %Y"', filePath],
{
stdio: 'pipe',
}
);

const fileContent = (await readFile(filePath, 'utf8')).split('\n');
const cleanDate = stdout.replace('\n', '').replaceAll('"', '');
const modificationDateLine = `modificationDate: ${cleanDate}`;

if (!fileContent[1].startsWith('modificationDate')) {
fileContent.splice(1, 0, modificationDateLine);
}

await writeFile(filePath, fileContent.join('\n'), 'utf8');
}
}

process.exit();
} catch (error) {
console.error(error);
process.exit(1);
}
}

appendModificationDate();
1 change: 1 addition & 0 deletions docs/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type PageMetadata = {
hideFromSearch?: boolean;
hideTOC?: boolean;
platforms?: string[];
modificationDate?: string;
};

/**
Expand Down
29 changes: 26 additions & 3 deletions docs/ui/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,33 @@ import { NewsletterSignUp } from './NewsletterSignUp';
import { PageVote } from './PageVote';

import { NavigationRouteWithSection } from '~/types/common';
import { P, FOOTNOTE, UL } from '~/ui/components/Text';
import { P, FOOTNOTE, UL, LI } from '~/ui/components/Text';

type Props = {
title?: string;
sourceCodeUrl?: string;
packageName?: string;
previousPage?: NavigationRouteWithSection;
nextPage?: NavigationRouteWithSection;
modificationDate?: string;
};

export const Footer = ({ title, sourceCodeUrl, packageName, previousPage, nextPage }: Props) => {
const isDev = process.env.NODE_ENV === 'development';

export const Footer = ({
title,
sourceCodeUrl,
packageName,
previousPage,
nextPage,
modificationDate,
}: Props) => {
const router = useRouter();
const isAPIPage = router?.pathname.includes('/sdk/') ?? false;
const isExpoPackage = packageName && packageName.startsWith('expo-');
const isTutorial = router?.pathname.includes('/tutorial/') ?? false;
const isExpoPackage = packageName ? packageName.startsWith('expo-') : isAPIPage;

const shouldShowModifiedDate = !isExpoPackage && !isTutorial;

return (
<footer
Expand Down Expand Up @@ -86,6 +99,16 @@ export const Footer = ({ title, sourceCodeUrl, packageName, previousPage, nextPa
<IssuesLink title={title} repositoryUrl={isExpoPackage ? undefined : sourceCodeUrl} />
)}
{title && router?.pathname && <EditPageLink pathname={router.pathname} />}
{!isDev && shouldShowModifiedDate && modificationDate && (
<LI className="!text-quaternary !text-2xs !mt-4">
Last updated on {modificationDate}
</LI>
)}
{isDev && shouldShowModifiedDate && (
<LI className="!text-quaternary !text-2xs !mt-4">
Last updated data is not available in dev mode
</LI>
)}
</UL>
</div>
<NewsletterSignUp />
Expand Down
7 changes: 7 additions & 0 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,13 @@
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f"
integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==

"@expo/spawn-async@^1.7.2":
version "1.7.2"
resolved "https://registry.yarnpkg.com/@expo/spawn-async/-/spawn-async-1.7.2.tgz#fcfe66c3e387245e72154b1a7eae8cada6a47f58"
integrity sha512-QdWi16+CHB9JYP7gma19OVVg0BFkvU8zNj9GjWorYI8Iv8FUxjOCcYRuAmX4s/h91e4e7BPsskc8cSrZYho9Ew==
dependencies:
cross-spawn "^7.0.3"

"@expo/styleguide-base@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@expo/styleguide-base/-/styleguide-base-1.0.1.tgz#c05b64370fc1754ed7e3c627fd2d788582445cd2"
Expand Down
Loading