Просмотр исходного кода

feat(docs): Write AssetOptions docs, tweak styles

Michael Bromley 7 лет назад
Родитель
Сommit
d42c76780a

+ 6 - 0
docs/assets/styles/main.scss

@@ -34,6 +34,12 @@ body {
     }
 }
 
+footer {
+    margin-top: 100px;
+    background-color: #efefef;
+    padding: 50px;
+}
+
 h1,
 h2,
 h3,

+ 0 - 6
docs/content/docs/config-asset-options.md

@@ -1,6 +0,0 @@
----
-title: "assetOptions"
-weight: 1
----
-
-# assetOptions

+ 5 - 1
docs/content/docs/configuration.md → docs/content/docs/configuration/_index.md

@@ -53,13 +53,17 @@ bootstrap({
 
 All possible configuration options are defined by the [`VendureConfig`](https://github.com/vendure-ecommerce/vendure/blob/master/server/src/config/vendure-config.ts) interface.
 
+{{% alert %}}
+Note on terminology: many of the configuration properties are named "Strategy" - this is because their use follows the [Strategy Pattern](https://en.wikipedia.org/wiki/Strategy_pattern) of software design.
+{{% /alert %}}
+
 ### apiPath
 
 The path to the GraphQL API.
 
 ### assetOptions
 
-Configuration for the handling of Assets (images and other files). See [assetOptions](/docs/config-asset-options).
+Configuration for the handling of Assets (images and other files). See [assetOptions]({{< ref "config-asset-options.md" >}}).
 
 ### authOptions
 

+ 37 - 0
docs/content/docs/configuration/config-asset-options.md

@@ -0,0 +1,37 @@
+---
+title: "Asset Options"
+weight: 1
+---
+
+# Asset Options
+
+The `AssetOptions` define how assets (images and other files) are named and stored, and how preview images are generated.
+
+
+## AssetNamingStrategy
+
+This class defines how the asset file will be named when being stored after upload, including how to deal with naming conflicts with existing files. 
+
+By default the `DefaultAssetNamingStrategy` is used, which normalizes the original file name and in the case of conflicts, appends a number to the end.
+
+## AssetStorageStrategy
+
+This defines how the asset files are stored to disk and retrieved. For example, if you wish to store assets on a cloud server such as Amazon S3, you can create a strategy for that.
+
+{{% alert warning %}}
+By default, the `NoAssetStorageStrategy` is used, which simply throws an error whenever an operation is attempted. Therefore, a valid strategy *must* be set in order to work with assets. The simplest way to do this is to use the `DefaultAssetServerPlugin`.
+{{% /alert %}}
+
+## AssetPreviewStrategy
+
+This defines how preview images of assets are generated. Typically, a preview image would be a scaled-down version of the original file, so that if the source image is a 2MB, 3000 x 4000 pixel photo, the preview could be limited to some maximum dimensions. Additionally, non-image assets (e.g. pdfs, audio files) require preview images.
+
+A use-case for writing a custom `AssetPreviewStrategy` could be the case of a business selling royalty-free music samples. In this case, the asset would be an audio file, and the custom strategy could include code which generates a visual waveform representation of the audio.
+
+{{% alert warning %}}
+By default, the `NoAssetPreviewStrategy` is used, which simply throws an error whenever an operation is attempted. Therefore, a valid strategy *must* be set in order to work with assets. The simplest way to do this is to use the `DefaultAssetServerPlugin`.
+{{% /alert %}}
+
+## uploadMaxFileSize
+
+Sets the max file size in bytes for uploaded assets. Defaults to 20,971,520 bytes (20MiB).

+ 1 - 1
docs/content/docs/config-auth-options.md → docs/content/docs/configuration/config-auth-options.md

@@ -1,5 +1,5 @@
 ---
-title: authOptions"
+title: authOptions
 weight: 1
 ---
 

+ 0 - 0
docs/content/docs/config-custom-fields.md → docs/content/docs/configuration/config-custom-fields.md


+ 0 - 0
docs/content/docs/config-email-options.md → docs/content/docs/configuration/config-email-options.md


+ 0 - 0
docs/content/docs/config-order-process-options.md → docs/content/docs/configuration/config-order-process-options.md


+ 0 - 0
docs/content/docs/config-payment-options.md → docs/content/docs/configuration/config-payment-options.md


+ 0 - 0
docs/content/docs/config-promotion-options.md → docs/content/docs/configuration/config-promotion-options.md


+ 0 - 0
docs/content/docs/config-shipping-options.md → docs/content/docs/configuration/config-shipping-options.md


+ 0 - 0
docs/content/docs/config-tax-options.md → docs/content/docs/configuration/config-tax-options.md


+ 1 - 1
docs/content/docs/getting-started.md

@@ -1,6 +1,6 @@
 ---
 title: "Getting Started"
-weight: 1
+weight: 0
 ---
 
 # Getting Started

+ 1 - 1
docs/content/docs/plugins.md

@@ -1,6 +1,6 @@
 ---
 title: "Plugins"
-weight: 1
+weight: 2
 ---
  
 # Plugins

+ 4 - 0
docs/layouts/partials/docs/inject/body.html

@@ -1 +1,5 @@
 {{ partial "top-bar" (dict "isLandingPage" false) }}
+
+<footer>
+
+</footer>

+ 3 - 0
docs/layouts/shortcodes/alert.html

@@ -0,0 +1,3 @@
+<div class='alert {{ index .Params 0 | default "primary" }}'>
+    {{ .Inner }}
+</div>

+ 2 - 5
server/src/config/vendure-config.ts

@@ -121,14 +121,11 @@ export interface AssetOptions {
      */
     assetNamingStrategy: AssetNamingStrategy;
     /**
-     * Defines the strategy used for storing uploaded binary files. By default files are
-     * persisted to the local file system.
+     * Defines the strategy used for storing uploaded binary files.
      */
     assetStorageStrategy: AssetStorageStrategy;
     /**
-     * Defines the strategy used for creating preview images of uploaded assets. The default
-     * strategy resizes images based on maximum dimensions and outputs a sensible default
-     * preview image for other file types.
+     * Defines the strategy used for creating preview images of uploaded assets.
      */
     assetPreviewStrategy: AssetPreviewStrategy;
     /**