Russ Cox | 6ba27a4 | 2021-02-12 14:32:52 -0500 | [diff] [blame] | 1 | // Copyright 2013 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
Russ Cox | 6ba27a4 | 2021-02-12 14:32:52 -0500 | [diff] [blame] | 5 | // Package website exports the static content as an embed.FS. |
| 6 | package website |
| 7 | |
| 8 | import ( |
Russ Cox | 5091754 | 2021-08-20 10:18:33 -0400 | [diff] [blame] | 9 | "embed" |
Russ Cox | a3cb310 | 2021-08-20 10:31:05 -0400 | [diff] [blame] | 10 | "io/fs" |
Russ Cox | 6ba27a4 | 2021-02-12 14:32:52 -0500 | [diff] [blame] | 11 | ) |
| 12 | |
Russ Cox | e77adb1 | 2021-11-18 10:55:19 -0500 | [diff] [blame] | 13 | // Content returns the go.dev website's static content. |
| 14 | func Content() fs.FS { |
| 15 | return subdir(embedded, "_content") |
| 16 | } |
| 17 | |
| 18 | // TourOnly returns the content needed only for the standalone tour. |
| 19 | func TourOnly() fs.FS { |
| 20 | return subdir(tourOnly, "_content") |
| 21 | } |
Russ Cox | 6ba27a4 | 2021-02-12 14:32:52 -0500 | [diff] [blame] | 22 | |
Russ Cox | 40c0eef | 2021-11-17 22:51:08 -0500 | [diff] [blame] | 23 | //go:embed _content |
Russ Cox | 5091754 | 2021-08-20 10:18:33 -0400 | [diff] [blame] | 24 | var embedded embed.FS |
Russ Cox | 6ba27a4 | 2021-02-12 14:32:52 -0500 | [diff] [blame] | 25 | |
Russ Cox | ad69553 | 2021-11-22 21:57:27 -0500 | [diff] [blame] | 26 | //go:embed _content/favicon.ico |
| 27 | //go:embed _content/images/go-logo-white.svg |
Hana (Hyang-Ah) Kim | 2918f44 | 2023-09-11 17:35:58 -0400 | [diff] [blame] | 28 | //go:embed _content/images/icons |
Russ Cox | ad69553 | 2021-11-22 21:57:27 -0500 | [diff] [blame] | 29 | //go:embed _content/js/playground.js |
| 30 | //go:embed _content/tour |
Russ Cox | e77adb1 | 2021-11-18 10:55:19 -0500 | [diff] [blame] | 31 | var tourOnly embed.FS |
| 32 | |
Russ Cox | 6ba27a4 | 2021-02-12 14:32:52 -0500 | [diff] [blame] | 33 | func subdir(fsys fs.FS, path string) fs.FS { |
| 34 | s, err := fs.Sub(fsys, path) |
| 35 | if err != nil { |
| 36 | panic(err) |
| 37 | } |
| 38 | return s |
| 39 | } |