[ci] yarn format

This commit is contained in:
matthewp 2021-08-16 20:44:46 +00:00 committed by GitHub Actions
parent 78b5bde14c
commit 24a40bee63
6 changed files with 10 additions and 18 deletions

View file

@ -76,13 +76,13 @@ const path = Astro.site.pathname;
`Astro.resolve()` helps with creating URLs relative to the current Astro file, allowing you to reference files within your `src/` folder.
Astro *does not* resolve relative links within HTML, such as images:
Astro _does not_ resolve relative links within HTML, such as images:
```html
<img src="../images/penguin.png" />
```
The above will be sent to the browser as-is and the browser will resolve it relative to the current __page__. If you want it to be resolved relative to the .astro file you are working in, use `Astro.resolve`:
The above will be sent to the browser as-is and the browser will resolve it relative to the current **page**. If you want it to be resolved relative to the .astro file you are working in, use `Astro.resolve`:
```astro
<img src={Astro.resolve('../images/penguin.png')} />

View file

@ -59,8 +59,6 @@ function findHydrationAttributes(attrs: Record<string, string>): HydrationAttrib
return { method, value };
}
/** Retrieve attributes from TemplateNode */
async function getAttributes(nodeName: string, attrs: Attribute[], state: CodegenState, compileOptions: CompileOptions): Promise<Record<string, string>> {
let result: Record<string, string> = {};

View file

@ -7,4 +7,4 @@ export interface Attribute {
name: string;
value: TemplateNode[] | boolean;
expression?: Expression;
}
}

View file

@ -22,20 +22,14 @@ export function isImportMetaDeclaration(declaration: VariableDeclarator, metaNam
return true;
}
const warnableRelativeValues = new Set([
'img+src',
'a+href',
'script+src',
'link+href',
'source+srcset'
]);
const warnableRelativeValues = new Set(['img+src', 'a+href', 'script+src', 'link+href', 'source+srcset']);
const matchesRelative = /^(?![A-Za-z][+-.0-9A-Za-z]*:|\/)/;
export function warnIfRelativeStringLiteral(logging: LogOptions, nodeName: string, attr: Attribute, value: string) {
let key = nodeName + '+' + attr.name;
if(warnableRelativeValues.has(key) && matchesRelative.test(value)) {
if (warnableRelativeValues.has(key) && matchesRelative.test(value)) {
let message = `This value will be resolved relative to the page: <${nodeName} ${attr.name}="${value}">`;
warn(logging, 'relative-link', message);
}
}
}

View file

@ -7,8 +7,8 @@ const GlobalBuild = suite('Astro.* built');
setup(GlobalBuild, './fixtures/astro-global', {
runtimeOptions: {
mode: 'production'
}
mode: 'production',
},
});
GlobalBuild('Astro.resolve in the build', async (context) => {
@ -20,4 +20,4 @@ GlobalBuild('Astro.resolve in the build', async (context) => {
assert.equal($('img').attr('src'), '/blog/_astro/src/images/penguin.png');
});
GlobalBuild.run();
GlobalBuild.run();

View file

@ -50,4 +50,4 @@ Global('Astro.resolve in development', async (context) => {
assert.equal($('img').attr('src'), '/_astro/src/images/penguin.png');
});
Global.run();
Global.run();