mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 12:09:26 +00:00
prettier
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import * as path from "node:path"
|
||||
import * as path from 'node:path';
|
||||
import { anchorHeadingsPlugin } from './_utils/anchor-headings.js';
|
||||
import { codeExamplesPlugin } from './_utils/code-examples.js';
|
||||
import { copyCodePlugin } from './_utils/copy-code.js';
|
||||
@@ -30,10 +30,10 @@ const globalData = {
|
||||
layout: 'page.njk',
|
||||
|
||||
server: {
|
||||
head: "",
|
||||
loginOrAvatar: "",
|
||||
flashes: "",
|
||||
}
|
||||
head: '',
|
||||
loginOrAvatar: '',
|
||||
flashes: '',
|
||||
},
|
||||
};
|
||||
|
||||
const passThroughExtensions = ['js', 'css', 'png', 'svg', 'jpg', 'mp4'];
|
||||
@@ -65,7 +65,7 @@ export default function (eleventyConfig) {
|
||||
|
||||
// Shortcodes - {% shortCode arg1, arg2 %}
|
||||
eleventyConfig.addShortcode('cdnUrl', location => {
|
||||
return `https://early.webawesome.com/webawesome@${packageData.version}/dist/` + (location || "").replace(/^\//, '');
|
||||
return `https://early.webawesome.com/webawesome@${packageData.version}/dist/` + (location || '').replace(/^\//, '');
|
||||
});
|
||||
|
||||
// Turns `{% server_variable "foo" %} into `{{ server.foo | safe }}`
|
||||
@@ -146,8 +146,8 @@ export default function (eleventyConfig) {
|
||||
.filter(component => !omittedModules.includes(component.tagName.split(/wa-/)[1]))
|
||||
.map(component => {
|
||||
const name = component.tagName.split(/wa-/)[1];
|
||||
const componentDirectory = process.env.UNBUNDLED_DIST_DIRECTORY || path.join(".", "dist")
|
||||
return path.join(componentDirectory, "components", name, `${name}.js`);
|
||||
const componentDirectory = process.env.UNBUNDLED_DIST_DIRECTORY || path.join('.', 'dist');
|
||||
return path.join(componentDirectory, 'components', name, `${name}.js`);
|
||||
});
|
||||
|
||||
eleventyConfig.addPlugin(litPlugin, {
|
||||
|
||||
@@ -5,10 +5,10 @@ import { deleteAsync } from 'del';
|
||||
import esbuild from 'esbuild';
|
||||
import { replace } from 'esbuild-plugin-replace';
|
||||
|
||||
import nunjucks from "nunjucks"
|
||||
import { mkdir, readFile } from 'fs/promises';
|
||||
import getPort, { portNumbers } from 'get-port';
|
||||
import { globby } from 'globby';
|
||||
import nunjucks from 'nunjucks';
|
||||
import ora from 'ora';
|
||||
import { dirname, join, relative } from 'path';
|
||||
import process from 'process';
|
||||
@@ -44,7 +44,7 @@ async function buildAll() {
|
||||
await copy(cdnDir, distDir, { overwrite: true });
|
||||
|
||||
await generateBundle();
|
||||
await generateDocs();
|
||||
await generateDocs();
|
||||
|
||||
const time = (Date.now() - start) / 1000 + 's';
|
||||
spinner.succeed(`The build is complete ${chalk.gray(`(finished in ${time})`)}`);
|
||||
@@ -269,10 +269,10 @@ async function regenerateBundle() {
|
||||
*/
|
||||
async function generateDocs() {
|
||||
/**
|
||||
* Used by the webawesome-app to skip doc generation since it will do its own.
|
||||
*/
|
||||
if (process.env.SKIP_ELEVENTY === "true") {
|
||||
return
|
||||
* Used by the webawesome-app to skip doc generation since it will do its own.
|
||||
*/
|
||||
if (process.env.SKIP_ELEVENTY === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
spinner.start('Writing the docs');
|
||||
@@ -348,36 +348,35 @@ if (isDeveloping) {
|
||||
middleware: [
|
||||
function (req, res, next) {
|
||||
// Accumulator for strings so we can pass them through EJS.
|
||||
const finalString = []
|
||||
const encoding = "utf-8"
|
||||
const finalString = [];
|
||||
const encoding = 'utf-8';
|
||||
|
||||
const _write = res.write
|
||||
res.write = function(chunk, encoding) {
|
||||
finalString.push(chunk.toString())
|
||||
}
|
||||
const _write = res.write;
|
||||
res.write = function (chunk, encoding) {
|
||||
finalString.push(chunk.toString());
|
||||
};
|
||||
|
||||
const _end = res.end
|
||||
const _end = res.end;
|
||||
res.end = function (...args) {
|
||||
const transformedStr = nunjucks.renderString(finalString.join(""), {
|
||||
const transformedStr = nunjucks.renderString(finalString.join(''), {
|
||||
// Stub the server EJS shortcodes.
|
||||
server: {
|
||||
head: "",
|
||||
loginOrAvatar: "",
|
||||
flashes: "",
|
||||
}
|
||||
})
|
||||
_write.call(res, transformedStr, encoding)
|
||||
_end.call(res, ...args)
|
||||
}
|
||||
head: '',
|
||||
loginOrAvatar: '',
|
||||
flashes: '',
|
||||
},
|
||||
});
|
||||
_write.call(res, transformedStr, encoding);
|
||||
_end.call(res, ...args);
|
||||
};
|
||||
|
||||
next()
|
||||
}
|
||||
next();
|
||||
},
|
||||
],
|
||||
callbacks: {
|
||||
ready: (_err, instance) => {
|
||||
// 404 errors
|
||||
instance.addMiddleware('*', async (req, res) => {
|
||||
|
||||
if (req.url.toLowerCase().endsWith('.svg')) {
|
||||
// Make sure SVGs error out in dev instead of serve the 404 page
|
||||
res.writeHead(404);
|
||||
@@ -393,7 +392,6 @@ if (isDeveloping) {
|
||||
|
||||
res.end();
|
||||
});
|
||||
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -169,7 +169,7 @@ export default class WaButton extends WebAwesomeFormAssociatedElement {
|
||||
}
|
||||
button.value = this.value || '';
|
||||
|
||||
;['form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach(attr => {
|
||||
['form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach(attr => {
|
||||
if (this.hasAttribute(attr)) {
|
||||
button.setAttribute(attr, this.getAttribute(attr)!);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user