1
1
# USDS Site Editor
2
2
3
+ This tool addresses the error-prone part of adding or editing posts on the Jekyll Frontmatter website,
4
+ editing the yaml header and markdown content using WYSIWYG editor and guided forms modals.
5
+
3
6
A static-html, front-end React client to edit markdown and have it look visually similar to how it appears on the final
4
7
site.
5
8
@@ -9,6 +12,8 @@ Results of edits can be saved to the local device as a zip file, including any i
9
12
10
13
Site is github pages deployed here: https://usds.github.io/website-content-editor/
11
14
15
+
16
+
12
17
## What's working:
13
18
14
19
- Heavily leverages the open source project: [ MDXEditor] ( https://github.com/mdx-editor/editor )
@@ -18,7 +23,7 @@ Site is github pages deployed here: https://usds.github.io/website-content-edito
18
23
- Downloads zip file of the markdown and images ready to submitted (all without a server)
19
24
- Can "upload" some existing markdown to make quick edits.
20
25
21
- ## Developers
26
+ # Developers
22
27
1 . To deploy, merge ` main ` branch into ` gh-pages ` . [ See branches] ( https://github.com/usds/website-content-editor/branches )
23
28
1 . The [ deploy action] ( https://github.com/usds/website-content-editor/actions ) will automatically run.
24
29
1 . Go to the github hosted website: https://usds.github.io/website-content-editor/
@@ -30,3 +35,79 @@ Site is github pages deployed here: https://usds.github.io/website-content-edito
30
35
- Link component showing offsite links correctly
31
36
- Help pages for how to merge in markdown edits back into website
32
37
- Need to reorganize code. Lots of things should be separated out into components.
38
+
39
+ ## Build
40
+ The build scripts are all standard Vite stuff:
41
+ - ` dev ` Builds + watches + runs the site in development mode.
42
+ - ` build ` Builds ` production ` mode into the ` dist/ ` directory
43
+ - ` preview ` Starts up a webserver pointing to ` dist/ ` directory to check release builds
44
+ - ` update ` Is the ` yarn ` command to update dependencies
45
+
46
+ ### Some build exception - because... of course
47
+ The service-worker is a non-standard. The normal usage of a service-worker is to provide an offline app.
48
+
49
+ OUR usage is to allow embedded images in the rich editor to function without a server.
50
+
51
+ Build-wise, the service worker script is standard ` .js ` and the two files
52
+ are copied directly into the ` dist/ ` directory. Because ` registerSW.js `
53
+ and ` service-worker.js ` are standard javascript, they are ** not** transpiled
54
+ and they don't import anything. So, some constants associated with the cache
55
+ are duplicated and need to kept in sync.
56
+
57
+ ## Service-Worker
58
+
59
+
60
+ ## Security
61
+ Site is 100% static. All content is stored in the browser's cache and localstorage.
62
+
63
+
64
+ ### Content-Security-Policy
65
+ Since it's running on github.io, we cannot set a CSP http header.
66
+ The next best thing is a ` <meta> ` header.
67
+
68
+ Vite dev mode uses hot reloading, which uses unsafe ` eval ` , so for
69
+ localdev, the CSP is disabled.
70
+
71
+ Enable/disable is done via the ` .env.development ` ` .env.production ` files.
72
+
73
+ Here's the current CSP:
74
+ ``` html
75
+ <meta http-equiv =" Content-Security-Policy"
76
+ content ="
77
+ base-uri 'self';
78
+ default-src 'self';
79
+ script-src 'self';
80
+ style-src 'self' https://usds.github.io/ https://usds.gov/ 'unsafe-inline';
81
+ img-src 'self' https: data: blob:;
82
+ font-src 'self' https://usds.github.io/ https://usds.gov/ https://*.gov/;
83
+ form-action 'none';
84
+ worker-src 'self' https: data: blob:;" >
85
+ ```
86
+
87
+ #### csp scripting
88
+ The most important items are:
89
+ ```
90
+ default-src 'self';
91
+ script-src 'self';
92
+ ```
93
+ These lock down scripting to just the site and prevents ` eval ` injections.
94
+
95
+ #### csp style
96
+ ```
97
+ style-src 'self' https://usds.github.io/ https://usds.gov/ 'unsafe-inline';
98
+ ```
99
+ The tool loads style scripts from website staging.
100
+
101
+ ` unsafe-inline ` is required because some of the 3rd party tools dynamically sets ` style= ` attribute.
102
+
103
+ #### csp images
104
+ ```
105
+ img-src 'self' https: data: blob:;
106
+ ```
107
+ The ` https: ` allows images to be loaded from anywhere. This allows the
108
+
109
+
110
+ ## Debugging
111
+
112
+ [ details about how to debug a service worker]
113
+
0 commit comments