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

Integrate multiple md files from c2patool repo #77

Merged
merged 7 commits into from
Aug 28, 2023
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
.docusaurus
.cache-loader
/docs/js-sdk/api
/docs/c2patool
/docs/rust-sdk
/docs/**/readme.md

# Misc
Expand All @@ -21,4 +23,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

.dccache
.dccache
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ $ npm start

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Running fetch script

The `/scripts/fetch-readme.js` script pulls markdown files from other repos (e.g. `c2patool`). To rerun this script for local build, enter this command:

```
npm run docs:fetch-readme
```

## Build

```
Expand All @@ -37,7 +45,7 @@ should be created automatically so that the preview can be shared before merging

### Forcing a site rebuild

To rebuild the site when one of the SDK/tool repos hasn't been versioned, simply make any change to the `main` branch of this repo. This is a workaround until a manual site rebuild capability is added.
To rebuild the site when one of the SDK/tool repos hasn't been versioned, simply make any change to the `main` branch of this repo. This is a workaround until a manual site rebuild capability is added.

## License

Expand Down
25 changes: 22 additions & 3 deletions scripts/fetch-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ const readmes = [
repo: 'contentauth/c2patool',
path: 'README.md',
},
{
dest: resolve(__dirname, '../docs/c2patool/manifest.md'),
repo: 'contentauth/c2patool',
path: 'docs/manifest.md',
},
{
dest: resolve(__dirname, '../docs/c2patool/x_509.md'),
repo: 'contentauth/c2patool',
path: 'docs/x_509.md',
},
{
dest: resolve(__dirname, '../docs/c2patool/release-notes.md'),
repo: 'contentauth/c2patool',
path: 'docs/release-notes.md',
},
{
dest: resolve(__dirname, '../docs/c2pa-service-example/readme.md'),
repo: 'contentauth/c2pa-service-example',
Expand All @@ -47,9 +62,13 @@ function resolveMarkdownLinks(linkBase, content) {
}

async function download() {
for await (const { repo, path, dest } of readmes) {
const src = `${RAW_GITHUB_HOST}/${repo}/main/${path}`;
const linkBase = `${GITHUB_HOST}/${repo}/blob/main/${path}`;
for await (const { repo, path, dest, branch = 'main' } of readmes) {
/*
* Pass {branch} var to pull docs from other than main branch.
*/

const src = `${RAW_GITHUB_HOST}/${repo}/${branch}/${path}`;
const linkBase = `${GITHUB_HOST}/${repo}/blob/${branch}/${path}`;
const res = await fetch(src);
const markdown = await res.text();
const resolvedMarkdown = resolveMarkdownLinks(linkBase, markdown);
Expand Down
12 changes: 12 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ const sidebars = {
type: 'doc',
id: 'c2patool/readme',
},
{
type: 'doc',
id: 'c2patool/manifest',
},
{
type: 'doc',
id: 'c2patool/x_509',
},
{
type: 'doc',
id: 'c2patool/release-notes',
},
{
type: 'doc',
id: 'c2pa-service-example/readme',
Expand Down