Skip to content

Commit 5339366

Browse files
committed
Add repo/docs links to plugins and switch site to light theme
- info.json: add `website` to plugins that have a dprint.dev docs page - derive each plugin's GitHub `repoUrl` during the info build - show `repo`/`docs` links beneath each plugin name and index them in search - recolor the site from the dark palette to a light/white theme
1 parent 1e5c255 commit 5339366

5 files changed

Lines changed: 142 additions & 49 deletions

File tree

homeView.tsx

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function renderHomeHtml(pluginsData: PluginsData) {
1010
<head>
1111
<meta charset="utf-8" />
1212
<meta name="viewport" content="width=device-width,initial-scale=1" />
13-
<meta name="theme-color" content="#1e1e1e" />
13+
<meta name="theme-color" content="#ffffff" />
1414
<meta name="description" content="Latest plugin versions for dprint, the pluggable and configurable code formatting platform." />
1515
<title>Plugins - dprint</title>
1616
<link rel="preconnect" href="https://fonts.googleapis.com" />
@@ -105,6 +105,8 @@ function pluginSearchText(plugin: PluginData) {
105105
plugin.version,
106106
plugin.description,
107107
plugin.configKey,
108+
plugin.repoUrl,
109+
plugin.website,
108110
...(plugin.keywords ?? []),
109111
...(plugin.fileExtensions ?? []),
110112
...(plugin.fileNames ?? []),
@@ -158,8 +160,13 @@ function renderPlugin(plugin: PluginData) {
158160
<div class="plugin-row" role="row" key={plugin.name} data-search={pluginSearchText(plugin)}>
159161
<div class="col-name" role="cell">
160162
<span class="swatch"></span>
161-
<span class="name-text">{plugin.name}</span>
162-
{plugin.version ? <span class="version-tag">{plugin.version}</span> : null}
163+
<div class="name-block">
164+
<div class="name-line">
165+
<span class="name-text">{plugin.name}</span>
166+
{plugin.version ? <span class="version-tag">{plugin.version}</span> : null}
167+
</div>
168+
{renderPluginLinks(plugin)}
169+
</div>
163170
</div>
164171
<div class="col-url" role="cell">
165172
<code>{plugin.url}</code>
@@ -176,3 +183,30 @@ function renderPlugin(plugin: PluginData) {
176183
</div>
177184
);
178185
}
186+
187+
// the repo and docs links shown beneath a plugin's name. both are optional: the
188+
// repo url is derived during the build and docs only exist for plugins with a
189+
// dprint.dev page.
190+
function renderPluginLinks(plugin: PluginData) {
191+
if (plugin.repoUrl == null && plugin.website == null) {
192+
return null;
193+
}
194+
return (
195+
<div class="plugin-links">
196+
{plugin.repoUrl
197+
? (
198+
<a href={plugin.repoUrl} target="_blank" rel="noopener noreferrer">
199+
repo <span></span>
200+
</a>
201+
)
202+
: null}
203+
{plugin.website
204+
? (
205+
<a href={plugin.website} target="_blank" rel="noopener noreferrer">
206+
docs <span></span>
207+
</a>
208+
)
209+
: null}
210+
</div>
211+
);
212+
}

info.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{
66
"name": "dprint-plugin-typescript",
77
"description": "TypeScript/JavaScript code formatter.",
8+
"website": "https://dprint.dev/plugins/typescript/",
89
"selected": true,
910
"configKey": "typescript",
1011
"keywords": [
@@ -31,6 +32,7 @@
3132
{
3233
"name": "dprint-plugin-json",
3334
"description": "JSON/JSONC code formatter.",
35+
"website": "https://dprint.dev/plugins/json/",
3436
"selected": true,
3537
"configKey": "json",
3638
"keywords": [
@@ -48,6 +50,7 @@
4850
{
4951
"name": "dprint-plugin-markdown",
5052
"description": "Markdown code formatter.",
53+
"website": "https://dprint.dev/plugins/markdown/",
5154
"selected": true,
5255
"configKey": "markdown",
5356
"keywords": [
@@ -68,6 +71,7 @@
6871
{
6972
"name": "dprint-plugin-toml",
7073
"description": "TOML code formatter.",
74+
"website": "https://dprint.dev/plugins/toml/",
7175
"selected": true,
7276
"configKey": "toml",
7377
"keywords": [
@@ -82,6 +86,7 @@
8286
{
8387
"name": "dprint-plugin-dockerfile",
8488
"description": "Dockerfile code formatter.",
89+
"website": "https://dprint.dev/plugins/dockerfile/",
8590
"selected": false,
8691
"configKey": "dockerfile",
8792
"keywords": [
@@ -100,6 +105,7 @@
100105
{
101106
"name": "dprint-plugin-biome",
102107
"description": "Biome (JS/TS/JSON) wrapper plugin.",
108+
"website": "https://dprint.dev/plugins/biome/",
103109
"selected": false,
104110
"configKey": "biome",
105111
"keywords": [
@@ -128,6 +134,7 @@
128134
{
129135
"name": "dprint-plugin-oxc",
130136
"description": "Oxc (JS/TS) wrapper plugin.",
137+
"website": "https://dprint.dev/plugins/oxc/",
131138
"selected": false,
132139
"configKey": "oxc",
133140
"keywords": [
@@ -153,6 +160,7 @@
153160
{
154161
"name": "dprint-plugin-mago",
155162
"description": "Mago (PHP) wrapper plugin.",
163+
"website": "https://dprint.dev/plugins/mago/",
156164
"selected": false,
157165
"configKey": "mago",
158166
"keywords": [
@@ -168,6 +176,7 @@
168176
{
169177
"name": "dprint-plugin-ruff",
170178
"description": "Ruff (Python) wrapper plugin.",
179+
"website": "https://dprint.dev/plugins/ruff/",
171180
"selected": false,
172181
"configKey": "ruff",
173182
"keywords": [
@@ -185,6 +194,7 @@
185194
{
186195
"name": "dprint-plugin-jupyter",
187196
"description": "Jupyter notebook code block formatter.",
197+
"website": "https://dprint.dev/plugins/jupyter/",
188198
"selected": false,
189199
"configKey": "jupyter",
190200
"keywords": [
@@ -201,6 +211,7 @@
201211
{
202212
"name": "jakebailey/gofumpt",
203213
"description": "Gofumpt (Go) wrapper plugin.",
214+
"website": "https://dprint.dev/plugins/gofumpt/",
204215
"selected": false,
205216
"configKey": "gofumpt",
206217
"keywords": [
@@ -217,6 +228,7 @@
217228
{
218229
"name": "g-plane/malva",
219230
"description": "CSS, SCSS, Sass and Less formatter.",
231+
"website": "https://dprint.dev/plugins/malva/",
220232
"selected": true,
221233
"configKey": "malva",
222234
"keywords": [
@@ -239,6 +251,7 @@
239251
{
240252
"name": "g-plane/markup_fmt",
241253
"description": "HTML, Vue, Svelte, Astro, Angular, Jinja, Twig, Nunjucks, and Vento formatter.",
254+
"website": "https://dprint.dev/plugins/markup_fmt/",
242255
"selected": true,
243256
"configKey": "markup",
244257
"keywords": [
@@ -284,6 +297,7 @@
284297
{
285298
"name": "g-plane/pretty_yaml",
286299
"description": "YAML formatter.",
300+
"website": "https://dprint.dev/plugins/pretty_yaml/",
287301
"selected": true,
288302
"configKey": "yaml",
289303
"keywords": [
@@ -301,6 +315,7 @@
301315
{
302316
"name": "g-plane/pretty_graphql",
303317
"description": "GraphQL formatter.",
318+
"website": "https://dprint.dev/plugins/pretty_graphql/",
304319
"selected": false,
305320
"configKey": "graphql",
306321
"keywords": [
@@ -422,6 +437,7 @@
422437
{
423438
"name": "dprint-plugin-prettier",
424439
"description": "Prettier wrapper plugin (consider faster dedicated plugins for JS/TS, CSS, etc.).",
440+
"website": "https://dprint.dev/plugins/prettier/",
425441
"selected": false,
426442
"configKey": "prettier",
427443
"keywords": [
@@ -466,6 +482,7 @@
466482
{
467483
"name": "dprint-plugin-roslyn",
468484
"description": "C# and Visual Basic code formatter (Roslyn).",
485+
"website": "https://dprint.dev/plugins/roslyn/",
469486
"selected": false,
470487
"configKey": "roslyn",
471488
"keywords": [
@@ -486,6 +503,7 @@
486503
{
487504
"name": "dprint-plugin-exec",
488505
"description": "Formats code using formatting CLIs installed on the host machine (rustfmt, clang-format, shfmt, etc.).",
506+
"website": "https://dprint.dev/plugins/exec/",
489507
"selected": false,
490508
"configKey": "exec",
491509
"keywords": [

plugins.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ export async function getLatestInfo(username: string, repoName: string, origin:
149149
: `${origin}/${username}/${displayRepoName}-${releaseInfo.tagName}.${extension}`,
150150
version: releaseInfo.tagName.replace(/^v/, ""),
151151
checksum: releaseInfo.checksum,
152+
// the GitHub repo this plugin is published from (full name already resolved above)
153+
repoUrl: `https://github.com/${username}/${repoName}`,
152154
// identifies this plugin's download analytics: the `username/repo` key that
153155
// downloads are recorded under and the tag of the latest release
154156
downloadKey: `${username}/${repoName}`,

readInfoFile.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export interface PluginData {
1616
currentVersion: number;
1717
allVersions: number;
1818
};
19+
// links shown on the site: the GitHub repo (derived during the build) and the
20+
// optional dprint.dev docs page (carried over from info.json)
21+
repoUrl?: string;
22+
website?: string;
1923
// descriptive fields carried over from info.json, used to index the search
2024
description?: string;
2125
configKey?: string;
@@ -152,6 +156,7 @@ async function buildInfoFile(origin: string): Promise<Readonly<PluginsData>> {
152156
...plugin,
153157
version: info.version,
154158
url: info.url,
159+
repoUrl: info.repoUrl,
155160
downloadCount: {
156161
currentVersion: currentVersionDownloads(counts, info.tag),
157162
allVersions: counts?.allVersions ?? 0,

0 commit comments

Comments
 (0)