對(duì)于 Web 開(kāi)發(fā)的入門(mén)者而言 , 開(kāi)發(fā)一個(gè)功能全面的靜態(tài)的網(wǎng)站首頁(yè) , 并不是那么容易實(shí)現(xiàn)的需求 。然而 , 實(shí)現(xiàn)一個(gè)個(gè)人網(wǎng)站或企業(yè)網(wǎng)站的簡(jiǎn)單首頁(yè),又是十分常見(jiàn)的需求 。如果可以通過(guò)編寫(xiě)簡(jiǎn)單的配置文件,就能實(shí)現(xiàn)一個(gè)美觀使用的靜態(tài)首頁(yè),并能夠提供一些自定義的功能 , 無(wú)疑會(huì)降低此類(lèi)需求開(kāi)發(fā)的門(mén)檻 。

文章插圖
Homer
簡(jiǎn)介Homer,是 bastienwirtz 在 Github 上開(kāi)源的靜態(tài)網(wǎng)站首頁(yè)生成器,通過(guò)簡(jiǎn)單的 yaml 配置文件就能實(shí)現(xiàn),目前版本為 v21.03.2 。
Homer 使用簡(jiǎn)單 ,
- 使用 yaml 格式的配置文件配置
- 可安裝 (pwa)
- 提供搜索功能
- 提供分組功能
- 提供主題自定義功能
- 提供離線 heathcheck 功能
- 實(shí)現(xiàn)快捷鍵:/ 開(kāi)始搜索,Escape 停止搜索,Enter 打開(kāi)首個(gè)匹配結(jié)果,Alter/Option + Enter 在新標(biāo)簽開(kāi)啟結(jié)果

文章插圖
Homer
使用Homer 是一個(gè)完全靜態(tài)的 html/js 管理面板,使用 webpack 從 /src 中進(jìn)行生成 。Homer 需要使用一個(gè) HTTP 服務(wù)器來(lái)提供服務(wù) 。
Homer 可以使用 Docker 啟動(dòng):
docker run -d \-p 8080:8080 \-v </your/local/assets/>:/www/assets \--restart=always \b4bz/homer:latest默認(rèn)的靜態(tài)資源或被自動(dòng)安裝在 /www/assets 文件夾,使用 UID 和 GID 環(huán)境變量來(lái)改變資源所有者 。也可以使用 Docker-Compose 啟動(dòng),配置 docker-compose.yml:
volumes:- /your/local/assets/:/www/assetsports:- 8080:8080啟動(dòng)容器,cd /path/to/docker-compose.ymldocker-compose up -d也可以下載預(yù)編譯的 tarball 直接使用 , 下載 homer.zip 文件 , 重命名 assets/config.yml.dist 文件為 assets/config.yml:wget https://github.com/bastienwirtz/homer/releases/latest/download/homer.zipunzip homer.zipcd homercp assets/config.yml.dist assets/config.ymlnpx serve # or python -m http.server 8010 or apache, nginx ...可以自行進(jìn)行編譯:# Using yarn (recommended)yarn installyarn build# **OR** Using npmnpm installnpm run build【web網(wǎng)頁(yè)設(shè)計(jì)代碼分享 企業(yè)網(wǎng)站主頁(yè)制作代碼】啟動(dòng)后 , 就能看到 Homer 面板了 。
文章插圖
Homer
Homer 最主要使用一個(gè) yaml 格式的配置文件,一個(gè)樣例的配置文件 config.yml 如下:
---# Homepage configuration# See https://fontawesome.com/icons for icons options# Optional: Use external configuration file. # Using this will ignore remaining config in this file# externalConfig: https://example.com/server-luci/config.yamltitle: "App dashboard"subtitle: "Homer"# documentTitle: "Welcome" # Customize the browser tab textlogo: "assets/logo.png"# Alternatively a fa icon can be provided:# icon: "fas fa-skull-crossbones"header: true # Set to false to hide the headerfooter: '<p>Created with <span class="has-text-danger">??</span> with <a >bulma</a>, <a >vuejs</a> & <a >font awesome</a> // Fork me on <a ><i class="fab fa-github-alt"></i></a></p>' # set false if you want to hide it.columns: "3" # "auto" or number (must be a factor of 12: 1, 2, 3, 4, 6, 12)connectivityCheck: true # whether you want to display a message when the apps are not accessible anymore (VPN disconnected for example)# Optional themingtheme: default # 'default' or one of the themes available in 'src/assets/themes'.# Optional custom stylesheet# Will load custom CSS files. Especially useful for custom icon sets.# stylesheet:#- "assets/custom.css"# Here is the exhaustive list of customization parameters# However all value are optional and will fallback to default if not set.# if you want to change only some of the colors, feel free to remove all unused key.colors:light:highlight-primary: "#3367d6"highlight-secondary: "#4285f4"highlight-hover: "#5a95f5"background: "#f5f5f5"card-background: "#ffffff"text: "#363636"text-header: "#424242"text-title: "#303030"text-subtitle: "#424242"card-shadow: rgba(0, 0, 0, 0.1)link-hover: "#363636"background-image: "assets/your/light/bg.png"dark:highlight-primary: "#3367d6"highlight-secondary: "#4285f4"highlight-hover: "#5a95f5"background: "#131313"card-background: "#2b2b2b"text: "#eaeaea"text-header: "#ffffff"text-title: "#fafafa"text-subtitle: "#f5f5f5"card-shadow: rgba(0, 0, 0, 0.4)link-hover: "#ffdd57"background-image: "assets/your/dark/bg.png"# Optional messagemessage:# url: "https://<my-api-endpoint>" # Can fetch information from an endpoint to override value below.# mapping: # allows to map fields from the remote format to the one expected by Homer#title: 'id' # use value from field 'id' as title#content: 'value' # value from field 'value' as content# refreshInterval: 10000 # Optional: time interval to refresh message## Real example using chucknorris.io for showing Chuck Norris facts as messages:# url: https://api.chucknorris.io/jokes/random# mapping:#title: 'id'#content: 'value'# refreshInterval: 10000style: "is-warning"title: "Optional message!"icon: "fa fa-exclamation-triangle"content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit."# Optional navbar# links: [] # Allows for navbar (dark mode, layout, and search) without any linkslinks:- name: "Link 1"icon: "fab fa-github"url: "https://github.com/bastienwirtz/homer"target: "_blank" # optional html tag target attribute- name: "link 2"icon: "fas fa-book"url: "https://github.com/bastienwirtz/homer"# this will link to a second homer page that will load config from page2.yml and keep default config values as in config.yml file# see url field and assets/page.yml used in this example:- name: "Second Page"icon: "fas fa-file-alt"url: "#page2"# Services# First level array represents a group.# Leave only a "items" key if not using group (group name, icon & tagstyle are optional, section separation will not be displayed).services:- name: "Application"icon: "fas fa-code-branch"# A path to an image can also be provided. Note that icon take precedence if both icon and logo are set.# logo: "path/to/logo"items:- name: "Awesome app"logo: "assets/tools/sample.png"# Alternatively a fa icon can be provided:# icon: "fab fa-jenkins"subtitle: "Bookmark example"tag: "app"url: "https://www.reddit.com/r/selfhosted/"target: "_blank" # optional html tag target attribute- name: "Another one"logo: "assets/tools/sample2.png"subtitle: "Another application"tag: "app"# Optional tagstyletagstyle: "is-success"url: "#"- name: "Other group"icon: "fas fa-heartbeat"items:- name: "Pi-hole"logo: "assets/tools/sample.png"# subtitle: "Network-wide Ad Blocking" # optional, if no subtitle is defined, PiHole statistics will be showntag: "other"url: "http://192.168.0.151/admin"type: "PiHole" # optional, loads a specific component that provides extra features. MUST MATCH a file name (without file extension) available in `src/components/services`target: "_blank" # optional html a tag target attribute# class: "green" # optional custom CSS class for card, useful with custom stylesheet# background: red # optional color for card to set color directly without custom stylesheet可以看到,提供了包括:標(biāo)題、子標(biāo)題、圖表、主題、顏色風(fēng)格、鏈接、子服務(wù)等配置 。Homer 通過(guò)以上的配置,就能自動(dòng)生成美觀的主頁(yè) 。
文章插圖
Homer
總結(jié)Homer 使用簡(jiǎn)單,使用 yaml 格式的配置文件配置 , 可安裝,提供搜索、分組功能,可自定義主題等,使實(shí)現(xiàn)一個(gè)網(wǎng)站的靜態(tài)首頁(yè)變得十分簡(jiǎn)單,同時(shí)提供了美觀且功能豐富的實(shí)現(xiàn)方案,值得使用 。
以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問(wèn)題,請(qǐng)您及時(shí)就醫(yī)或請(qǐng)專(zhuān)業(yè)人士給予相關(guān)指導(dǎo)!
「愛(ài)刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對(duì)您有所幫助:- SAP SD模塊中稅收國(guó)家地區(qū)代碼定義步驟
- 如何優(yōu)化C語(yǔ)言代碼以生成更少的機(jī)器碼
- 提升網(wǎng)頁(yè)設(shè)計(jì)效果:在線PS套索工具調(diào)出濾鏡庫(kù)的新技巧
- 教你如何制作Flash開(kāi)始播放按鈕代碼
- 如何使用VBA代碼自定義單元格貨幣符號(hào)
- Matlab斷點(diǎn)調(diào)試:提高代碼調(diào)試效率
- 解決寬帶連接錯(cuò)誤代碼711的方法
- 如何優(yōu)化NetBeans中的Web瀏覽器設(shè)置
- Java代碼實(shí)現(xiàn)獲取本機(jī)電腦IP地址
- 如何解決Eclipse運(yùn)行web程序時(shí)找不到類(lèi)的問(wèn)題
