0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

[ci] format

This commit is contained in:
Florian Lefebvre 2024-03-04 16:49:05 +00:00 committed by astrobot-houston
parent 992537e79f
commit 69ce70bb24
3 changed files with 10 additions and 8 deletions

View file

@ -16,8 +16,8 @@ import {
mergeInlineCss,
} from './internal.js';
import { ASTRO_PAGE_MODULE_ID, ASTRO_PAGE_RESOLVED_MODULE_ID } from './plugins/plugin-pages.js';
import { getVirtualModulePageNameFromPath } from './plugins/util.js';
import { RESOLVED_SPLIT_MODULE_ID } from './plugins/plugin-ssr.js';
import { getVirtualModulePageNameFromPath } from './plugins/util.js';
import { ASTRO_PAGE_EXTENSION_POST_PATTERN } from './plugins/util.js';
import type { PageBuildData, StaticBuildOptions } from './types.js';
import { i18nHasFallback } from './util.js';

View file

@ -45,7 +45,7 @@ export const ASTRO_PAGE_EXTENSION_POST_PATTERN = '@_@';
/**
* Prevents Rollup from triggering other plugins in the process by masking the extension (hence the virtual file).
*
*
* 1. We add a fixed prefix, which is used as virtual module naming convention
* 2. If the path has an extension (at the end of the path), we replace the dot that belongs to the extension with an arbitrary string.
*
@ -54,10 +54,12 @@ export const ASTRO_PAGE_EXTENSION_POST_PATTERN = '@_@';
*/
export function getVirtualModulePageNameFromPath(virtualModulePrefix: string, path: string) {
const extension = extname(path);
return virtualModulePrefix +
return (
virtualModulePrefix +
(extension.startsWith('.')
? path.slice(0, -extension.length) + extension.replace('.', ASTRO_PAGE_EXTENSION_POST_PATTERN)
: path);
: path)
);
}
/**

View file

@ -1,11 +1,11 @@
import assert from 'node:assert/strict';
import { mkdirSync, writeFileSync } from 'node:fs';
import { dirname } from 'node:path';
import { before, describe, it } from 'node:test';
import { fileURLToPath } from 'node:url';
import { load as cheerioLoad } from 'cheerio';
import testAdapter from './test-adapter.js';
import { loadFixture } from './test-utils.js';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { mkdirSync, writeFileSync } from 'node:fs';
describe('Dynamic pages in SSR', () => {
/** @type {import('./test-utils').Fixture} */
@ -29,7 +29,7 @@ describe('Dynamic pages in SSR', () => {
const entrypoint = fileURLToPath(
new URL(`${root}.astro/test.astro`, import.meta.url)
);
console.log(entrypoint)
console.log(entrypoint);
mkdirSync(dirname(entrypoint), { recursive: true });
writeFileSync(entrypoint, '<h1>Index</h1>');