Skip to content

Commit

Permalink
fix: could not use dynamic import in deno deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
kawarimidoll committed Sep 21, 2021
1 parent ec2ad65 commit d5b87e9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 45 deletions.
27 changes: 0 additions & 27 deletions diplodocus.ts

This file was deleted.

18 changes: 18 additions & 0 deletions diplodocus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sourceDir: docs
siteName: Diplodocus
description: Static Asset Server for Deno Deploy
navLinks:
- path: docs
- path: examples
- path: lorem
- path: acknowledgements
- title: Links
items:
- path: "https://github.com/kawarimidoll/deno-diplodocus"
title: GitHub
- path: "https://deno.land/x/diplodocus"
title: deno.land/x
listPages:
- title: Docs
path: docs
- path: lorem
17 changes: 4 additions & 13 deletions docs/docs/02_site_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Diplodocus works without any settings, but there are some configurable options.

Diplodocus accepts YAML, JSON or TypeScript configuration files. The file should
be `diplodocus.(yaml|yml|json|ts)` in the same directory with the entry point
file of Deno Deploy such as `server.ts`.
be `diplodocus.(yaml|yml|json)` in the same directory with the entry point file
of Deno Deploy such as `server.ts`.

```sh
├── docs/
Expand All @@ -13,7 +13,7 @@ file of Deno Deploy such as `server.ts`.
```

If there are multiple configuration files, Diplodocus will choose one of them by
this priority: (high) `yaml` `yml` `json` `ts` (low).
this priority: (high) `yaml` `yml` `json` (low).

## Format

Expand All @@ -31,19 +31,10 @@ sourceDir: docs
}
```

### diplodocus.ts

```ts
export default {
sourceDir: "docs",
};
```

## Available Keys

These values below can be used to configure Diplodocus. All of them are
optional. If you use function-type key, the configuration file should be a
TypeScript file.
optional.

### sourceDir

Expand Down
9 changes: 4 additions & 5 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,12 @@ export class Diplodocus {
files.push(file.name);
}
console.log(files);
for (const ext of ["yaml", "yml", "json", "ts"]) {
for (const ext of ["yaml", "yml", "json"]) {
const configFile = `diplodocus.${ext}`;
if (files.includes(configFile)) {
const loadedData = ext === "ts"
? (await import(`${Deno.cwd()}/${configFile}`)).default
: parseYaml(await Deno.readTextFile(configFile));
userConfig = loadedData as UserConfig;
userConfig = parseYaml(
await Deno.readTextFile(configFile),
) as UserConfig;
break;
}
}
Expand Down

0 comments on commit d5b87e9

Please sign in to comment.