Skip to content

Build plugins docs during the website build#42

Merged
DmitrySharabin merged 11 commits intov2from
plugins
May 9, 2025
Merged

Build plugins docs during the website build#42
DmitrySharabin merged 11 commits intov2from
plugins

Conversation

@DmitrySharabin
Copy link
Member

@DmitrySharabin DmitrySharabin commented May 7, 2025

First iteration.

Depends on PrismJS/prism#3930

}

let name = path.parse(file.name).name;
// Don't copy the plugin source files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if instead of excluding files based on heuristics we only include README.md and demo.*?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first attempt was exactly what you proposed. However, later, I realized that plugin docs might depend on other files, such as external stylesheets, scripts, images, data files, etc., and we don't know what names they might have. The only thing we can be sure of, though, is that we don't want to copy the plugin source files whose names happen to end with the plugin ID. So, I decided to follow that route.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They shouldn't though. And if they do, they can always include them via HTML in README.md. I think it's okay to restrict what plugins can do in their docs a bit if it leads to a more predictable structure and less clutter in the source repo.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, okay then. I'll fix it

import * as filters from "./filters.js";

import components from "prismjs/src/components.json" with { type: "json" };
import components from "../node_modules/prismjs/src/components.json" with { type: "json" };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do this? I would expect 11ty's regular collections to work just fine if we apply good tags etc (which we can do at the directory level).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still depend on this when building a list of supported languages on the main page and a list of languages and themes that might be included in a bundle on the Download page.

I'm planning to ditch it in the following PRs. I didn't want to work on this in this PR since it seems orthogonal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. And yes, we can eventually ditch it. For plugins, we already have their readmes that should contain all their metadata as 11ty data. For languages, that would be too heavyweight, so we could follow a mixed approach: Declare their metadata at the top of the file using a doc comment (that is then picked up by our build process), and have MD files for those that want to declare more details. Then, our build tool produces MD files for the rest. These pages should also host the examples for each language, which are currently a separate app with questionable UX where you select the languages you want to see examples of via checkboxes (which seems clever, but is not how anyone looks for examples of certain languages, so it just becomes a hassle)

@DmitrySharabin
Copy link
Member Author

I think we are ready for another iteration.

@DmitrySharabin DmitrySharabin requested a review from LeaVerou May 8, 2025 15:12
@DmitrySharabin DmitrySharabin mentioned this pull request May 8, 2025
8 tasks
/plugins/:plugin/index.html /plugins/:plugin/index.html 200
/plugins/:plugin/demo.html /plugins/:plugin/demo.html 200
/plugins/:plugin/demo.js /plugins/:plugin/demo.js 200
/plugins/:plugin/demo.css /plugins/:plugin/demo.css 200
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, these seem to be redirecting to themselves?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No wonder. This looks weird, I agree. The following redirect rule also covers these cases, but we don't want to redirect those files (they live in the website repo). Due to limitations of the _redirects files, this is the only (and most straightforward) way to achieve our goal.

ChatGPT says we can try Netlify Edge functions for this. I haven't tried it yet, but I will probably do so in the next iteration.

@DmitrySharabin DmitrySharabin merged commit 68a2499 into v2 May 9, 2025
3 checks passed
@DmitrySharabin DmitrySharabin deleted the plugins branch May 9, 2025 10:49
DmitrySharabin added a commit that referenced this pull request May 12, 2025
* Add copy script

* Adjust the build process

* Add `_redirects`

* Fix plugin URLs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants