Skip to content

Commit

Permalink
Merge branch 'main' into jc/give-plugins-their-options-back
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber authored Nov 10, 2021
2 parents f71458d + ecce576 commit 9aadb5e
Show file tree
Hide file tree
Showing 89 changed files with 869 additions and 550 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-blog-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

jobs:
build:
name: Build Blog-only
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Size Report
name: Build Performance

on:
# Note! you can't safely use "pull_request_target" here
Expand All @@ -9,9 +9,12 @@ on:
pull_request:
branches:
- main
paths-ignore:
- website/docs/**

jobs:
build:
build-size:
name: Build Size Report
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
Expand All @@ -27,3 +30,25 @@ jobs:
strip-hash: '\.([^;]\w{7})\.'
minimum-change-threshold: 30
compression: none
build-time:
name: Build Time Perf
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
cache: yarn
- name: Installation
run: yarn

# Ensure build with a cold cache does not increase too much
- name: Build (cold cache)
run: yarn workspace website build --locale en
timeout-minutes: 8

# Ensure build with a warm cache does not increase too much
- name: Build (warm cache)
run: yarn workspace website build --locale en
timeout-minutes: 2
# TODO post a Github comment with build with perf warnings?
31 changes: 0 additions & 31 deletions .github/workflows/build-time-perf.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/canary-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

jobs:
publish-canary:
name: Publish Canary
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lighthouse-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ on:
- main

jobs:
build:
lighthouse-report:
name: Lighthouse Report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
lint:
name: Lint
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: Tests E2E
name: E2E Tests

on:
push:
branches:
- main
paths-ignore:
- website/**
pull_request:
branches:
- main
paths-ignore:
- website/**

jobs:
yarn-v1:
name: E2E — Yarn v1
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -42,6 +47,7 @@ jobs:
CI: true

yarn-berry:
name: E2E — Yarn Berry
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/tests-windows.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ on:
pull_request:
branches:
- main
paths-ignore:
- website/**

jobs:
test:
name: Tests
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
Expand All @@ -25,3 +28,26 @@ jobs:
run: yarn test
- name: TypeCheck website
run: yarn workspace website tsc
windows-test:
name: Windows Tests
timeout-minutes: 30
runs-on: windows-latest
strategy:
matrix:
node: ['14', '16', '17']
steps:
- name: Support longpaths
run: git config --system core.longpaths true
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Installation
run: yarn || yarn || yarn # 3 attempts to avoid timeout errors...
- name: Docusaurus Jest Tests
run: yarn test
- name: Docusaurus Build
run: yarn build:website --locale en
env:
CI: true
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A new document is now available at `http://localhost:3000/docs/hello`.

Docusaurus automatically **creates a sidebar** from the `docs` folder.

Add metadatas to customize the sidebar label and position:
Add metadata to customize the sidebar label and position:

```md title="docs/hello.md" {1-4}
---
Expand Down
2 changes: 1 addition & 1 deletion examples/classic/docs/tutorial-basics/create-a-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A new document is now available at `http://localhost:3000/docs/hello`.

Docusaurus automatically **creates a sidebar** from the `docs` folder.

Add metadatas to customize the sidebar label and position:
Add metadata to customize the sidebar label and position:

```md title="docs/hello.md" {1-4}
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A new document is now available at `http://localhost:3000/docs/hello`.

Docusaurus automatically **creates a sidebar** from the `docs` folder.

Add metadatas to customize the sidebar label and position:
Add metadata to customize the sidebar label and position:

```md title="docs/hello.md" {1-4}
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A new document is now available at `http://localhost:3000/docs/hello`.

Docusaurus automatically **creates a sidebar** from the `docs` folder.

Add metadatas to customize the sidebar label and position:
Add metadata to customize the sidebar label and position:

```md title="docs/hello.md" {1-4}
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`toRedirectFilesMetadata should create appropriate metadatas for empty baseUrl: fileContent baseUrl=empty 1`] = `
exports[`toRedirectFilesMetadata should create appropriate metadata for empty baseUrl: fileContent baseUrl=empty 1`] = `
Array [
"<!DOCTYPE html>
<html>
Expand All @@ -16,7 +16,7 @@ Array [
]
`;

exports[`toRedirectFilesMetadata should create appropriate metadatas for root baseUrl: fileContent baseUrl=/ 1`] = `
exports[`toRedirectFilesMetadata should create appropriate metadata for root baseUrl: fileContent baseUrl=/ 1`] = `
Array [
"<!DOCTYPE html>
<html>
Expand All @@ -32,7 +32,7 @@ Array [
]
`;

exports[`toRedirectFilesMetadata should create appropriate metadatas trailingSlash=false: fileContent 1`] = `
exports[`toRedirectFilesMetadata should create appropriate metadata trailingSlash=false: fileContent 1`] = `
Array [
"<!DOCTYPE html>
<html>
Expand Down Expand Up @@ -70,7 +70,7 @@ Array [
]
`;

exports[`toRedirectFilesMetadata should create appropriate metadatas trailingSlash=true: fileContent 1`] = `
exports[`toRedirectFilesMetadata should create appropriate metadata trailingSlash=true: fileContent 1`] = `
Array [
"<!DOCTYPE html>
<html>
Expand Down Expand Up @@ -108,7 +108,7 @@ Array [
]
`;

exports[`toRedirectFilesMetadata should create appropriate metadatas trailingSlash=undefined: fileContent 1`] = `
exports[`toRedirectFilesMetadata should create appropriate metadata trailingSlash=undefined: fileContent 1`] = `
Array [
"<!DOCTYPE html>
<html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('createToUrl', () => {
});

describe('toRedirectFilesMetadata', () => {
test('should create appropriate metadatas trailingSlash=undefined', async () => {
test('should create appropriate metadata trailingSlash=undefined', async () => {
const pluginContext = {
outDir: '/tmp/someFixedOutDir',
baseUrl: 'https://docusaurus.io',
Expand All @@ -69,7 +69,7 @@ describe('toRedirectFilesMetadata', () => {
);
});

test('should create appropriate metadatas trailingSlash=true', async () => {
test('should create appropriate metadata trailingSlash=true', async () => {
const pluginContext = {
outDir: '/tmp/someFixedOutDir',
baseUrl: 'https://docusaurus.io',
Expand All @@ -96,7 +96,7 @@ describe('toRedirectFilesMetadata', () => {
);
});

test('should create appropriate metadatas trailingSlash=false', async () => {
test('should create appropriate metadata trailingSlash=false', async () => {
const pluginContext = {
outDir: '/tmp/someFixedOutDir',
baseUrl: 'https://docusaurus.io',
Expand Down Expand Up @@ -124,7 +124,7 @@ describe('toRedirectFilesMetadata', () => {
);
});

test('should create appropriate metadatas for root baseUrl', async () => {
test('should create appropriate metadata for root baseUrl', async () => {
const pluginContext = {
outDir: '/tmp/someFixedOutDir',
baseUrl: '/',
Expand All @@ -139,7 +139,7 @@ describe('toRedirectFilesMetadata', () => {
);
});

test('should create appropriate metadatas for empty baseUrl', async () => {
test('should create appropriate metadata for empty baseUrl', async () => {
const pluginContext = {
outDir: '/tmp/someFixedOutDir',
baseUrl: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,15 @@ describe('loadBlog', () => {
truncated: false,
});
});

test('test ascending sort direction of blog post', async () => {
const siteDir = path.join(__dirname, '__fixtures__', 'website');
const normalOrder = await getBlogPosts(siteDir);
const reversedOrder = await getBlogPosts(siteDir, {
sortPosts: 'ascending',
});
expect(normalOrder.reverse().map((x) => x.metadata.date)).toEqual(
reversedOrder.map((x) => x.metadata.date),
);
});
});
3 changes: 3 additions & 0 deletions packages/docusaurus-plugin-content-blog/src/blogUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ export async function generateBlogPosts(
(a, b) => b.metadata.date.getTime() - a.metadata.date.getTime(),
);

if (options.sortPosts === 'ascending') {
return blogPosts.reverse();
}
return blogPosts;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
editLocalizedFiles: false,
authorsMapPath: 'authors.yml',
readingTime: ({content, defaultReadingTime}) => defaultReadingTime({content}),
sortPosts: 'descending',
};

export const PluginOptionSchema = Joi.object<PluginOptions>({
Expand Down Expand Up @@ -115,4 +116,7 @@ export const PluginOptionSchema = Joi.object<PluginOptions>({
}).default(DEFAULT_OPTIONS.feedOptions),
authorsMapPath: Joi.string().default(DEFAULT_OPTIONS.authorsMapPath),
readingTime: Joi.function().default(() => DEFAULT_OPTIONS.readingTime),
sortPosts: Joi.string()
.valid('descending', 'ascending')
.default(DEFAULT_OPTIONS.sortPosts),
});
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-content-blog/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export type PluginOptions = RemarkAndRehypePluginOptions & {
admonitions: Record<string, unknown>;
authorsMapPath: string;
readingTime: ReadingTimeFunctionOption;
sortPosts: 'ascending' | 'descending';
};

// Options, as provided in the user config (before normalization)
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"chalk": "^4.1.2",
"combine-promises": "^1.1.0",
"escape-string-regexp": "^4.0.0",
"execa": "^5.0.0",
"fs-extra": "^10.0.0",
"globby": "^11.0.2",
"import-fresh": "^3.2.2",
Expand Down
Loading

0 comments on commit 9aadb5e

Please sign in to comment.