hack: filter content collection glob
This commit is contained in:
parent
c7e3c8d0e2
commit
119473921b
2 changed files with 13 additions and 10 deletions
|
@ -37,6 +37,15 @@ export function astroContentVirtualModPlugin({
|
||||||
const contentEntryExts = [...contentEntryConfigByExt.keys()];
|
const contentEntryExts = [...contentEntryConfigByExt.keys()];
|
||||||
const dataEntryExts = getDataEntryExts(settings);
|
const dataEntryExts = getDataEntryExts(settings);
|
||||||
|
|
||||||
|
let contentEntryGlobPath = globWithUnderscoresIgnored(relContentDir, contentEntryExts);
|
||||||
|
// HACK(nate): filter contentEntryGlobPath to simulate incremental build
|
||||||
|
contentEntryGlobPath = [contentEntryGlobPath[0].replace('**/*', '**/a-e*')]
|
||||||
|
|
||||||
|
const dataEntryGlobPath = globWithUnderscoresIgnored(relContentDir, dataEntryExts);
|
||||||
|
/** Note: data collections excluded */
|
||||||
|
let renderEntryGlobPath = globWithUnderscoresIgnored(relContentDir, contentEntryExts);
|
||||||
|
renderEntryGlobPath = [renderEntryGlobPath[0].replace('**/*', '**/a-e*')]
|
||||||
|
|
||||||
const virtualModContents = fsMod
|
const virtualModContents = fsMod
|
||||||
.readFileSync(contentPaths.virtualModTemplate, 'utf-8')
|
.readFileSync(contentPaths.virtualModTemplate, 'utf-8')
|
||||||
.replace(
|
.replace(
|
||||||
|
@ -46,20 +55,15 @@ export function astroContentVirtualModPlugin({
|
||||||
.replace('@@CONTENT_DIR@@', relContentDir)
|
.replace('@@CONTENT_DIR@@', relContentDir)
|
||||||
.replace(
|
.replace(
|
||||||
"'@@CONTENT_ENTRY_GLOB_PATH@@'",
|
"'@@CONTENT_ENTRY_GLOB_PATH@@'",
|
||||||
JSON.stringify(globWithUnderscoresIgnored(relContentDir, contentEntryExts))
|
JSON.stringify(contentEntryGlobPath)
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"'@@DATA_ENTRY_GLOB_PATH@@'",
|
"'@@DATA_ENTRY_GLOB_PATH@@'",
|
||||||
JSON.stringify(globWithUnderscoresIgnored(relContentDir, dataEntryExts))
|
JSON.stringify(dataEntryGlobPath)
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"'@@RENDER_ENTRY_GLOB_PATH@@'",
|
"'@@RENDER_ENTRY_GLOB_PATH@@'",
|
||||||
JSON.stringify(
|
JSON.stringify(renderEntryGlobPath)
|
||||||
globWithUnderscoresIgnored(
|
|
||||||
relContentDir,
|
|
||||||
/** Note: data collections excluded */ contentEntryExts
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const astroContentVirtualModuleId = '\0' + VIRTUAL_MODULE_ID;
|
const astroContentVirtualModuleId = '\0' + VIRTUAL_MODULE_ID;
|
||||||
|
|
|
@ -97,7 +97,6 @@ export async function viteBuild(opts: StaticBuildOptions) {
|
||||||
for (const output of ssrOutput.output) {
|
for (const output of ssrOutput.output) {
|
||||||
const md = output.moduleIds.filter(id => id.endsWith('.md'))
|
const md = output.moduleIds.filter(id => id.endsWith('.md'))
|
||||||
if (!!md) {
|
if (!!md) {
|
||||||
console.log(output.moduleIds);
|
|
||||||
// const { fileName: id, code: content } = output.moduleIds
|
// const { fileName: id, code: content } = output.moduleIds
|
||||||
// internals.cache.push({ input, output: { id, content } })
|
// internals.cache.push({ input, output: { id, content } })
|
||||||
}
|
}
|
||||||
|
@ -106,7 +105,7 @@ export async function viteBuild(opts: StaticBuildOptions) {
|
||||||
fs.writeFileSync(cacheFile, JSON.stringify(internals.cache), { encoding: 'utf8' });
|
fs.writeFileSync(cacheFile, JSON.stringify(internals.cache), { encoding: 'utf8' });
|
||||||
|
|
||||||
if (restore) {
|
if (restore) {
|
||||||
console.log('RESTORING CACHE');
|
// console.log('RESTORING CACHE');
|
||||||
for (const cached of internals.cache) {
|
for (const cached of internals.cache) {
|
||||||
fs.writeFileSync(new URL(`./${cached.output.id}`, settings.config.outDir), cached.output.content, { encoding: 'utf8' });
|
fs.writeFileSync(new URL(`./${cached.output.id}`, settings.config.outDir), cached.output.content, { encoding: 'utf8' });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue