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

feat: showcase #9967

Draft
wants to merge 87 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
2b37b51
wip init
OzakIOne Mar 20, 2024
f6b0d46
refactor: apply lint autofix
OzakIOne Mar 20, 2024
cd3908b
wip
OzakIOne Mar 21, 2024
a2516dc
refactor: apply lint autofix
OzakIOne Mar 21, 2024
7cf981c
wip routes per yaml
OzakIOne Mar 21, 2024
ec35998
refactor: apply lint autofix
OzakIOne Mar 21, 2024
8d1b174
wip
OzakIOne Mar 24, 2024
7daa9a1
refactor: apply lint autofix
OzakIOne Mar 24, 2024
c542c81
ShowcaseDetails component
OzakIOne Mar 24, 2024
dddb8cf
cspell autolint fix
OzakIOne Mar 24, 2024
1c825e0
refactor: apply lint autofix
OzakIOne Mar 24, 2024
9790934
wip markdown process: crash
OzakIOne Mar 25, 2024
49b6746
refactor: apply lint autofix
OzakIOne Mar 25, 2024
6e40a79
wip use plugin page code logic
OzakIOne Mar 26, 2024
984518e
fix: warning
OzakIOne Mar 26, 2024
993efd2
wip process markdown
OzakIOne Mar 26, 2024
8bee535
wip images
OzakIOne Mar 27, 2024
022efa3
refactor: apply lint autofix
OzakIOne Mar 27, 2024
30599c3
Update packages/docusaurus-plugin-showcase/package.json
OzakIOne Mar 29, 2024
bed9bb3
wip tests
OzakIOne Mar 29, 2024
c42c15e
refactor: apply lint autofix
OzakIOne Mar 29, 2024
e147034
wip tests
OzakIOne Mar 29, 2024
cdb7c07
consistent file naming
OzakIOne Mar 29, 2024
46c57d6
wip tags file validation
OzakIOne Mar 31, 2024
4a221f3
wip working tags from yaml
OzakIOne Apr 1, 2024
fc34725
prettier
OzakIOne Apr 1, 2024
6b83e2d
wip
OzakIOne Apr 1, 2024
c3f32ab
wip
OzakIOne Apr 1, 2024
8ab6dda
wip
OzakIOne Apr 1, 2024
45af11f
add tests
OzakIOne Apr 3, 2024
a9d6bcf
wip
OzakIOne Apr 4, 2024
91aa292
improve type
OzakIOne Apr 4, 2024
4cecd0c
wip
OzakIOne Apr 4, 2024
6670b7a
fix types
OzakIOne Apr 5, 2024
d9885db
dynamic validation
OzakIOne Apr 5, 2024
9eab6ae
move schema creation outside of loadcontent
OzakIOne Apr 5, 2024
0fdb9d6
wip tests
OzakIOne Apr 8, 2024
290cdb4
wip tests
OzakIOne Apr 8, 2024
65affab
wip tests
OzakIOne Apr 8, 2024
867b604
wip
OzakIOne Apr 9, 2024
e1c51bf
wip
OzakIOne Apr 9, 2024
c89f8be
Merge branch 'main' into ozaki/showcase
OzakIOne Apr 11, 2024
7a9418c
Merge branch 'main' into ozaki/showcase
OzakIOne Apr 11, 2024
047b5f0
versions
slorber Apr 11, 2024
3cef207
refactor: apply lint autofix
slorber Apr 11, 2024
c0a6520
yarnlock
slorber Apr 11, 2024
6435e9a
Merge remote-tracking branch 'origin/ozaki/showcase' into ozaki/showcase
slorber Apr 11, 2024
2af5b44
remove popper/tooltip
slorber Apr 11, 2024
8f9408c
refactor: apply lint autofix
slorber Apr 11, 2024
81acd87
showcase plugin client API setup
slorber Apr 11, 2024
4f64b33
Merge remote-tracking branch 'origin/ozaki/showcase' into ozaki/showcase
slorber Apr 11, 2024
0cfdd9d
hooks bypass extreme wip
OzakIOne Apr 11, 2024
c0c0f83
update with client showcase
OzakIOne Apr 15, 2024
7b76e46
fix type error
OzakIOne Apr 16, 2024
8504ad3
revert changes
OzakIOne Apr 16, 2024
1fb54b6
Merge branch 'main' into ozaki/showcase
OzakIOne Apr 16, 2024
ff16819
refactor: apply lint autofix
OzakIOne Apr 16, 2024
52bf244
wip showcase provider :D
OzakIOne Apr 16, 2024
c7cbafc
feat: new route props
OzakIOne Apr 16, 2024
5b6626b
wip
OzakIOne Apr 16, 2024
8c12b1c
wip
OzakIOne Apr 17, 2024
a4cb0ff
refactor: apply lint autofix
OzakIOne Apr 17, 2024
61a7650
add all sites
OzakIOne Apr 17, 2024
c903765
refactor: apply lint autofix
OzakIOne Apr 17, 2024
2855df5
allow null options
OzakIOne Apr 17, 2024
38a71a6
fix tests
OzakIOne Apr 17, 2024
c9a05e2
wip
OzakIOne Apr 19, 2024
8c1770b
admin script
OzakIOne Apr 19, 2024
7869eb9
Merge branch 'main' into ozaki/showcase
OzakIOne Apr 20, 2024
82858f8
fix build
OzakIOne Apr 20, 2024
77aaf4a
refactor: apply lint autofix
OzakIOne Apr 20, 2024
34a0e3f
update admin script
OzakIOne Apr 20, 2024
40000d0
refactor clean
OzakIOne Apr 20, 2024
510539f
refactor: apply lint autofix
OzakIOne Apr 20, 2024
c8b7e6d
screenshot api
OzakIOne Apr 20, 2024
01657b0
Merge branch 'main' into ozaki/showcase
slorber May 3, 2024
2c99553
Fix packages
slorber May 3, 2024
57665a8
adjust ts configs for showcase
slorber May 3, 2024
080949b
fix packages
slorber May 3, 2024
841c81f
normalize tsBuildInfoFile
slorber May 3, 2024
99a4c5f
Merge branch 'main' into ozaki/showcase
slorber May 13, 2024
7e417aa
remove bad MDX import
slorber May 13, 2024
8ad0747
wip routeContext
OzakIOne May 16, 2024
633397a
wip
OzakIOne May 16, 2024
77ee19e
fix unknown word test
OzakIOne May 16, 2024
27a57d0
refactor: apply lint autofix
OzakIOne May 16, 2024
dee675c
feat route context
OzakIOne May 16, 2024
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
62 changes: 62 additions & 0 deletions admin/scripts/showcaseCheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import path from 'path';
import yaml from 'js-yaml';
import {load} from 'cheerio';

async function parseFiles(directoryPath) {
try {
const files = await fs.promises.readdir(directoryPath);

for (const file of files) {
const filePath = path.join(directoryPath, file);
const stat = await fs.promises.stat(filePath);

if (stat.isDirectory()) {
await parseFiles(filePath); // Recursively process subdirectories
} else {
await processYamlFile(filePath); // Process individual YAML file
}
}
} catch (err) {
console.error('Error reading directory:', err);
}
}
async function processYamlFile(filePath) {
const data = await fs.promises.readFile(filePath, 'utf8');
const {website} = yaml.load(data);

try {
const html = await fetchWebsiteHtml(website);
const $ = load(html);
const generatorMeta = $('meta[name="generator"]');

if (generatorMeta.length === 0) {
console.log(`Website ${website} is not a Docusaurus site.`);
}
} catch (error) {
console.error(`Error fetching website ${website}:`, error.message);
}
}

async function fetchWebsiteHtml(url) {
const response = await fetch(url, {
headers: {
'Accept-Encoding': 'gzip, deflate',
},
});

if (!response.ok) {
throw new Error(`Failed to fetch ${url}: ${response.statusText}`);
}

return response.text();
}

// processYamlFiles('../../website/showcase');
parseFiles('./admin/scripts/showcase');
3 changes: 3 additions & 0 deletions packages/docusaurus-plugin-content-showcase/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.tsbuildinfo*
tsconfig*
__tests__
7 changes: 7 additions & 0 deletions packages/docusaurus-plugin-content-showcase/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# `@docusaurus/plugin-content-showcase`

Showcase plugin for Docusaurus.

## Usage

See [plugin-content-showcase documentation](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-showcase).
51 changes: 51 additions & 0 deletions packages/docusaurus-plugin-content-showcase/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@docusaurus/plugin-content-showcase",
"version": "3.3.2",
"description": "Showcase plugin for Docusaurus.",
"main": "lib/index.js",
"sideEffects": false,
"exports": {
"./lib/*": "./lib/*",
"./src/*": "./src/*",
"./client": {
"type": "./lib/client/index.d.ts",
"default": "./lib/client/index.js"
},
".": {
"types": "./src/plugin-content-showcase.d.ts",
"default": "./lib/index.js"
}
},
"types": "src/plugin-content-showcase.d.ts",
"scripts": {
"build": "tsc --build",
"watch": "tsc --build --watch"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/facebook/docusaurus.git",
"directory": "packages/docusaurus-plugin-content-showcase"
},
"license": "MIT",
"dependencies": {
"@docusaurus/core": "3.3.2",
"@docusaurus/types": "3.3.2",
"@docusaurus/utils": "3.3.2",
"@docusaurus/utils-validation": "3.3.2",
"@docusaurus/theme-common": "3.3.2",
"fs-extra": "^11.1.1",
"js-yaml": "^4.1.0",
"tslib": "^2.6.0",
"webpack": "^5.88.1"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"engines": {
"node": ">=18.0"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`docusaurus-plugin-content-showcase loads simple showcase 1`] = `
{
"items": [
{
"description": "World",
"preview": "github.com/ozakione.png",
"source": "https://github.com/facebook/docusaurus",
"tags": [
"opensource",
"meta",
],
"title": "Hello",
"website": "https://docusaurus.io/",
},
],
}
`;

exports[`docusaurus-plugin-content-showcase loads simple showcase with tags in options 1`] = `
{
"items": [
{
"description": "World",
"preview": "github.com/ozakione.png",
"source": "https://github.com/facebook/docusaurus",
"tags": [
"opensource",
"meta",
],
"title": "Hello",
"website": "https://docusaurus.io/",
},
],
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import path from 'path';
import {loadContext} from '@docusaurus/core/src/server/site';
import {normalizePluginOptions} from '@docusaurus/utils-validation';
import {fromPartial} from '@total-typescript/shoehorn';
import pluginContentShowcase from '../index';
import {validateOptions} from '../options';
import type {PluginOptions} from '@docusaurus/plugin-content-showcase';

const loadPluginContent = async (siteDir: string, options: PluginOptions) => {
const context = await loadContext({siteDir});
const plugin = await pluginContentShowcase(
context,
validateOptions({
validate: normalizePluginOptions,
options,
}),
);
return plugin.loadContent!();
};

describe('docusaurus-plugin-content-showcase', () => {
it('loads simple showcase', async () => {
const siteDir = path.join(__dirname, '__fixtures__', 'website');
const showcaseMetadata = await loadPluginContent(
siteDir,
fromPartial({
path: 'src/showcase',
tags: 'tags.yaml',
}),
);

expect(showcaseMetadata).toMatchSnapshot();
});

it('loads simple showcase with tags in options', async () => {
const tags = {
opensource: {
label: 'Open-Source',
description: {
message:
'Open-Source Docusaurus sites can be useful for inspiration!',
id: 'showcase.tag.opensource.description',
},
color: '#39ca30',
},
meta: {
label: 'Meta',
description: {
message: 'Docusaurus sites of Meta (formerly Facebook) projects',
id: 'showcase.tag.meta.description',
},
color: '#4267b2',
},
};
const siteDir = path.join(__dirname, '__fixtures__', 'website');
const showcaseMetadata = await loadPluginContent(
siteDir,
fromPartial({
path: 'src/showcase',
tags,
}),
);

expect(showcaseMetadata).toMatchSnapshot();
});

it('throw loading inexistant tags file', async () => {
const siteDir = path.join(__dirname, '__fixtures__', 'website');
await expect(async () => {
await loadPluginContent(
siteDir,
fromPartial({
path: 'src/showcase',
tags: 'wrong.yaml',
}),
);
}).rejects.toThrowErrorMatchingInlineSnapshot(
`"Failed to read tags file for showcase"`,
);
});
});
Loading
Loading