From 5fdf95526e44515d83f94709151ca9e3d36ad4ae Mon Sep 17 00:00:00 2001 From: Nick Schaap Date: Tue, 13 Dec 2022 18:28:09 -0500 Subject: [PATCH 1/7] fix(documentation): add base search url --- projects/documentation/package.json | 1 + projects/documentation/rollup.config.js | 7 +++++++ .../src/components/search-index.ts | 4 +++- .../documentation/src/components/styles.css | 4 ++-- yarn.lock | 17 ++++++++++++++++- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/projects/documentation/package.json b/projects/documentation/package.json index 54ba27feed..81eec85d0e 100644 --- a/projects/documentation/package.json +++ b/projects/documentation/package.json @@ -33,6 +33,7 @@ "@rollup/plugin-commonjs": "^21.0.1", "@rollup/plugin-json": "^5.0.0", "@rollup/plugin-node-resolve": "^13.1.3", + "@rollup/plugin-replace": "^5.0.1", "@toycode/markdown-it-class": "^1.2.4", "@types/lunr": "^2.3.3", "@types/prismjs": "^1.16.6", diff --git a/projects/documentation/rollup.config.js b/projects/documentation/rollup.config.js index 5911d65c38..4cc7b43f68 100644 --- a/projects/documentation/rollup.config.js +++ b/projects/documentation/rollup.config.js @@ -25,6 +25,7 @@ import Terser from 'terser'; const { postCSSPlugins } = require('../../scripts/css-processing.cjs'); import postCSSPrefixwrap from 'postcss-prefixwrap'; import { nodeResolve } from '@rollup/plugin-node-resolve'; +import replace from '@rollup/plugin-replace'; const stringReplaceHtml = (source) => { return source @@ -70,6 +71,12 @@ module.exports = async () => { exportConditions: ['browser', 'import', mode], }) ); + mpaConfig.plugins.push( + replace({ + include: '**/search-index.ts', + 'process.env.SWC_DIR': process.env.SWC_DIR, + }) + ); mpaConfig.plugins.push( html({ transformHtml: [ diff --git a/projects/documentation/src/components/search-index.ts b/projects/documentation/src/components/search-index.ts index 4d76229322..7849febfce 100644 --- a/projects/documentation/src/components/search-index.ts +++ b/projects/documentation/src/components/search-index.ts @@ -37,6 +37,8 @@ function label(name: string): string { ); } +const BASE_URL = process.env.SWC_DIR; + export async function search(value: string): Promise { if (!index) { const searchIndexURL = new URL('./searchIndex.json', import.meta.url) @@ -72,7 +74,7 @@ export async function search(value: string): Promise { catagoryData.results.push({ name, label: label(name), - url: item.ref, + url: BASE_URL + item.ref, }); } } diff --git a/projects/documentation/src/components/styles.css b/projects/documentation/src/components/styles.css index 97af0a59e8..623be0c05f 100644 --- a/projects/documentation/src/components/styles.css +++ b/projects/documentation/src/components/styles.css @@ -192,7 +192,7 @@ body { width: 36px; height: 31px; display: block; - margin-right: var(--spectrum-global-dimension-size-200); + margin-inline-end: var(--spectrum-spacing-300); margin-bottom: 12px; flex-shrink: 0; position: relative; @@ -737,4 +737,4 @@ icons-demo::part(search) { icons-demo::part(icon) { padding: calc(0.5 * var(--spectrum-global-dimension-static-size-200)) 0; gap: var(--spectrum-global-dimension-static-size-200); -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 01cc764b80..bc760513a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4062,6 +4062,14 @@ "@rollup/pluginutils" "^3.1.0" magic-string "^0.25.7" +"@rollup/plugin-replace@^5.0.1": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-5.0.1.tgz#49a57af3e6df111a9e75dea3f3572741f4c5c83e" + integrity sha512-Z3MfsJ4CK17BfGrZgvrcp/l6WXoKb0kokULO+zt/7bmcyayokDaQ2K3eDJcRLCTAlp5FPI4/gz9MHAsosz4Rag== + dependencies: + "@rollup/pluginutils" "^5.0.1" + magic-string "^0.26.4" + "@rollup/pluginutils@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" @@ -15010,6 +15018,13 @@ magic-string@^0.25.0, magic-string@^0.25.7: dependencies: sourcemap-codec "^1.4.4" +magic-string@^0.26.4: + version "0.26.7" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.26.7.tgz#caf7daf61b34e9982f8228c4527474dac8981d6f" + integrity sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow== + dependencies: + sourcemap-codec "^1.4.8" + make-dir@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" @@ -21256,7 +21271,7 @@ source-map@^0.8.0-beta.0: dependencies: whatwg-url "^7.0.0" -sourcemap-codec@^1.4.4: +sourcemap-codec@^1.4.4, sourcemap-codec@^1.4.8: version "1.4.8" resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== From 24d7498c4bd3f8ee205f576ab40ec46a8e8e4cff Mon Sep 17 00:00:00 2001 From: Nick Schaap Date: Wed, 14 Dec 2022 02:32:57 -0500 Subject: [PATCH 2/7] docs: inject base url at index build time --- packages/action-group/CHANGELOG.md | 2 +- projects/documentation/.eleventy.cjs | 31 ++++++++++--------- projects/documentation/package.json | 24 +++++++++++--- projects/documentation/rollup.config.js | 7 ----- projects/documentation/scripts/build-ts.js | 2 -- .../src/components/search-index.ts | 4 +-- .../utils/posthtml-spectrum-docs-markdown.js | 6 ++-- 7 files changed, 42 insertions(+), 34 deletions(-) diff --git a/packages/action-group/CHANGELOG.md b/packages/action-group/CHANGELOG.md index d92b3ee52f..9b82482aa0 100644 --- a/packages/action-group/CHANGELOG.md +++ b/packages/action-group/CHANGELOG.md @@ -5,7 +5,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [0.12.4](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/action-group@0.12.3...@spectrum-web-components/action-group@0.12.4) (2022-12-08) -**Note:** Version bump only for package @spectrum-web-components/action-group +**Note:** Version bum nly for package @spectrum-web-components/action-grou ## [0.12.3](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/action-group@0.12.2...@spectrum-web-components/action-group@0.12.3) (2022-11-21) diff --git a/projects/documentation/.eleventy.cjs b/projects/documentation/.eleventy.cjs index 272f877a97..350278ce18 100644 --- a/projects/documentation/.eleventy.cjs +++ b/projects/documentation/.eleventy.cjs @@ -77,23 +77,26 @@ module.exports = function (eleventyConfig) { }, }); - eleventyConfig.addTransform("transform-postHTML", async function(content, outputPath) { - const posthtml = await import('posthtml').then(module => module.default); - const spectrumMarkdown = await import('./src/utils/posthtml-spectrum-docs-markdown.js').then(module => module.default); - if( outputPath && outputPath.endsWith(".html") ) { - return posthtml() - .use(spectrumMarkdown()) - .process(content, { sync: true }) - .html + eleventyConfig.addTransform( + 'transform-postHTML', + async function (content, outputPath) { + const posthtml = await import('posthtml').then( + (module) => module.default + ); + const spectrumMarkdown = await import( + './src/utils/posthtml-spectrum-docs-markdown.js' + ).then((module) => module.default); + if (outputPath && outputPath.endsWith('.html')) { + return posthtml() + .use(spectrumMarkdown()) + .process(content, { sync: true }).html; + } + return content; // no change done. } - return content; // no change done. - }); - - eleventyConfig.setLibrary( - 'md', - markdown ); + eleventyConfig.setLibrary('md', markdown); + eleventyConfig.addCollection('guides', (collection) => { return [...collection.getFilteredByGlob('./content/guides/*.md')]; }); diff --git a/projects/documentation/package.json b/projects/documentation/package.json index 81eec85d0e..4d3a02a681 100644 --- a/projects/documentation/package.json +++ b/projects/documentation/package.json @@ -33,7 +33,6 @@ "@rollup/plugin-commonjs": "^21.0.1", "@rollup/plugin-json": "^5.0.0", "@rollup/plugin-node-resolve": "^13.1.3", - "@rollup/plugin-replace": "^5.0.1", "@toycode/markdown-it-class": "^1.2.4", "@types/lunr": "^2.3.3", "@types/prismjs": "^1.16.6", @@ -73,6 +72,9 @@ "dependencies": [ { "script": "build:assets" + }, + { + "script": "build:search-index" } ] }, @@ -86,9 +88,6 @@ }, { "script": "build:postcss" - }, - { - "script": "build:search-index" } ] }, @@ -139,11 +138,25 @@ "dependencies": [ { "script": "build:assets" + }, + { + "script": "build:search-index" } ] }, "build:search-index": { "command": "node scripts/build-search-index.js", + "files": [ + "../../packages/*/*.md", + "../../tools/*/*.md", + "./**/scripts/build-search-index.js" + ], + "output": [ + "dist/searchIndex.json" + ] + }, + "build:search-index:prod": { + "command": "SWC_DIR=spectrum-web-components node scripts/build-search-index.js", "files": [ "../../packages/*/*.md", "../../tools/*/*.md", @@ -197,6 +210,9 @@ { "script": "build:assets", "cascade": false + }, + { + "script": "build:search-index" } ] } diff --git a/projects/documentation/rollup.config.js b/projects/documentation/rollup.config.js index 4cc7b43f68..5911d65c38 100644 --- a/projects/documentation/rollup.config.js +++ b/projects/documentation/rollup.config.js @@ -25,7 +25,6 @@ import Terser from 'terser'; const { postCSSPlugins } = require('../../scripts/css-processing.cjs'); import postCSSPrefixwrap from 'postcss-prefixwrap'; import { nodeResolve } from '@rollup/plugin-node-resolve'; -import replace from '@rollup/plugin-replace'; const stringReplaceHtml = (source) => { return source @@ -71,12 +70,6 @@ module.exports = async () => { exportConditions: ['browser', 'import', mode], }) ); - mpaConfig.plugins.push( - replace({ - include: '**/search-index.ts', - 'process.env.SWC_DIR': process.env.SWC_DIR, - }) - ); mpaConfig.plugins.push( html({ transformHtml: [ diff --git a/projects/documentation/scripts/build-ts.js b/projects/documentation/scripts/build-ts.js index c8484739c2..b8010db126 100644 --- a/projects/documentation/scripts/build-ts.js +++ b/projects/documentation/scripts/build-ts.js @@ -13,8 +13,6 @@ governing permissions and limitations under the License. import { build } from 'esbuild'; import { litCssPlugin } from 'esbuild-plugin-lit-css'; import postcss from 'postcss'; -// import { postCSSPlugins } from '../../../scripts/css-processing.cjs'; -import purgecss from '@fullhuman/postcss-purgecss'; import postcssImport from 'postcss-import'; import postcssEnv from 'postcss-preset-env'; import cssnano from 'cssnano'; diff --git a/projects/documentation/src/components/search-index.ts b/projects/documentation/src/components/search-index.ts index 7849febfce..4d76229322 100644 --- a/projects/documentation/src/components/search-index.ts +++ b/projects/documentation/src/components/search-index.ts @@ -37,8 +37,6 @@ function label(name: string): string { ); } -const BASE_URL = process.env.SWC_DIR; - export async function search(value: string): Promise { if (!index) { const searchIndexURL = new URL('./searchIndex.json', import.meta.url) @@ -74,7 +72,7 @@ export async function search(value: string): Promise { catagoryData.results.push({ name, label: label(name), - url: BASE_URL + item.ref, + url: item.ref, }); } } diff --git a/projects/documentation/src/utils/posthtml-spectrum-docs-markdown.js b/projects/documentation/src/utils/posthtml-spectrum-docs-markdown.js index 2ad0ce99a4..e2e4db23be 100644 --- a/projects/documentation/src/utils/posthtml-spectrum-docs-markdown.js +++ b/projects/documentation/src/utils/posthtml-spectrum-docs-markdown.js @@ -10,13 +10,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag governing permissions and limitations under the License. */ -import postHTMLSpectrumTypeography from './posthtml-spectrum-typography.js'; -export { postHTMLSpectrumTypeography }; +import postHTMLSpectrumTypography from './posthtml-spectrum-typography.js'; +export { postHTMLSpectrumTypography }; // Add a few doc-specific transforms for code examples export default () => - postHTMLSpectrumTypeography({ + postHTMLSpectrumTypography({ customTransforms: [ { // take `
` tags where their first child is a `` tag,

From 608a8d4a2cd2f9c0ca51587d8e591cd4d900d511 Mon Sep 17 00:00:00 2001
From: Nick Schaap 
Date: Wed, 14 Dec 2022 02:35:05 -0500
Subject: [PATCH 3/7] docs: fix accidental commit

---
 packages/action-group/CHANGELOG.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/action-group/CHANGELOG.md b/packages/action-group/CHANGELOG.md
index 9b82482aa0..d92b3ee52f 100644
--- a/packages/action-group/CHANGELOG.md
+++ b/packages/action-group/CHANGELOG.md
@@ -5,7 +5,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
 
 ## [0.12.4](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/action-group@0.12.3...@spectrum-web-components/action-group@0.12.4) (2022-12-08)
 
-**Note:** Version bum nly for package @spectrum-web-components/action-grou
+**Note:** Version bump only for package @spectrum-web-components/action-group
 
 ## [0.12.3](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/action-group@0.12.2...@spectrum-web-components/action-group@0.12.3) (2022-11-21)
 

From cc5ba095349db2cfdbf2c04908be5680b5225623 Mon Sep 17 00:00:00 2001
From: Nick Schaap 
Date: Wed, 14 Dec 2022 02:39:03 -0500
Subject: [PATCH 4/7] docs: update yarn.lock

---
 yarn.lock | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/yarn.lock b/yarn.lock
index bc760513a9..01cc764b80 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4062,14 +4062,6 @@
     "@rollup/pluginutils" "^3.1.0"
     magic-string "^0.25.7"
 
-"@rollup/plugin-replace@^5.0.1":
-  version "5.0.1"
-  resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-5.0.1.tgz#49a57af3e6df111a9e75dea3f3572741f4c5c83e"
-  integrity sha512-Z3MfsJ4CK17BfGrZgvrcp/l6WXoKb0kokULO+zt/7bmcyayokDaQ2K3eDJcRLCTAlp5FPI4/gz9MHAsosz4Rag==
-  dependencies:
-    "@rollup/pluginutils" "^5.0.1"
-    magic-string "^0.26.4"
-
 "@rollup/pluginutils@^3.1.0":
   version "3.1.0"
   resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
@@ -15018,13 +15010,6 @@ magic-string@^0.25.0, magic-string@^0.25.7:
   dependencies:
     sourcemap-codec "^1.4.4"
 
-magic-string@^0.26.4:
-  version "0.26.7"
-  resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.26.7.tgz#caf7daf61b34e9982f8228c4527474dac8981d6f"
-  integrity sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow==
-  dependencies:
-    sourcemap-codec "^1.4.8"
-
 make-dir@^1.0.0:
   version "1.3.0"
   resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c"
@@ -21271,7 +21256,7 @@ source-map@^0.8.0-beta.0:
   dependencies:
     whatwg-url "^7.0.0"
 
-sourcemap-codec@^1.4.4, sourcemap-codec@^1.4.8:
+sourcemap-codec@^1.4.4:
   version "1.4.8"
   resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
   integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==

From a5e5136c8ab120afebc77d76fffc31605d2251df Mon Sep 17 00:00:00 2001
From: Nick Schaap 
Date: Wed, 14 Dec 2022 02:48:49 -0500
Subject: [PATCH 5/7] docs: typo

---
 projects/documentation/package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/projects/documentation/package.json b/projects/documentation/package.json
index 4d3a02a681..3535822420 100644
--- a/projects/documentation/package.json
+++ b/projects/documentation/package.json
@@ -140,7 +140,7 @@
                     "script": "build:assets"
                 },
                 {
-                    "script": "build:search-index"
+                    "script": "build:search-index:prod"
                 }
             ]
         },

From ee5608e99e24078710c403452a2d1b2ed3fdaa8a Mon Sep 17 00:00:00 2001
From: Nick Schaap 
Date: Wed, 14 Dec 2022 03:08:33 -0500
Subject: [PATCH 6/7] docs: add prod script to package.json

---
 projects/documentation/package.json | 1 +
 1 file changed, 1 insertion(+)

diff --git a/projects/documentation/package.json b/projects/documentation/package.json
index 3535822420..82739d98cf 100644
--- a/projects/documentation/package.json
+++ b/projects/documentation/package.json
@@ -15,6 +15,7 @@
         "build:postcss": "wireit",
         "build:production": "wireit",
         "build:search-index": "wireit",
+        "build:search-index:prod": "wireit",
         "build:tsc": "wireit",
         "copy-docs": "wireit",
         "serve": "wireit",

From 777e123a1952c7eced7c29699eaeca0f8ae17af9 Mon Sep 17 00:00:00 2001
From: Westbrook Johnson 
Date: Sun, 18 Dec 2022 19:36:26 -0500
Subject: [PATCH 7/7] build: Update projects/documentation/package.json

---
 projects/documentation/package.json | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/projects/documentation/package.json b/projects/documentation/package.json
index 82739d98cf..bcbcb17bf2 100644
--- a/projects/documentation/package.json
+++ b/projects/documentation/package.json
@@ -213,7 +213,8 @@
                     "cascade": false
                 },
                 {
-                    "script": "build:search-index"
+                    "script": "build:search-index",
+                    "cascade": false
                 }
             ]
         }