control search engine visibility

This commit is contained in:
LouisLam 2021-08-09 18:16:27 +08:00
parent ddcfa558f7
commit b69185ee9e
4 changed files with 16 additions and 10 deletions

View File

@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/svg+xml" href="/icon.svg"/> <link rel="icon" type="image/svg+xml" href="/icon.svg"/>
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"> <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="theme-color" content="#5cdd8b"/> <meta name="theme-color" content="#5cdd8b"/>
<meta name="description" content="Uptime Kuma monitoring tool"/> <meta name="description" content="Uptime Kuma monitoring tool"/>

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@ -88,16 +88,26 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
// Normal Router here // Normal Router here
app.use("/", express.static("dist")); // Robots.txt
app.get("/robots.txt", async (_request, response) => {
let txt = "User-agent: *\nDisallow:";
if (! await setting("searchEngineIndex")) {
txt += " /";
}
response.setHeader("Content-Type", "text/plain");
response.send(txt);
});
// Basic Auth Router here // Basic Auth Router here
// Prometheus API metrics /metrics // Prometheus API metrics /metrics
// With Basic Auth using the first user's username/password // With Basic Auth using the first user's username/password
app.get("/metrics", basicAuth, prometheusAPIMetrics()) app.get("/metrics", basicAuth, prometheusAPIMetrics());
app.use("/", express.static("dist"));
// Universal Route Handler, must be at the end // Universal Route Handler, must be at the end
app.get("*", function(_request, response) { app.get("*", async (_request, response) => {
response.send(indexHTML); response.send(indexHTML);
}); });

View File

@ -42,13 +42,13 @@
<label class="form-label">Search Engine Visibility</label> <label class="form-label">Search Engine Visibility</label>
<div class="form-check"> <div class="form-check">
<input id="searchEngineIndexYes" v-model="settings.searchEngineIndex" class="form-check-input" type="radio" name="flexRadioDefault"> <input id="searchEngineIndexYes" v-model="settings.searchEngineIndex" class="form-check-input" type="radio" name="flexRadioDefault" :value="true" required>
<label class="form-check-label" for="searchEngineIndexYes"> <label class="form-check-label" for="searchEngineIndexYes">
Allow indexing Allow indexing
</label> </label>
</div> </div>
<div class="form-check"> <div class="form-check">
<input id="searchEngineIndexNo" v-model="settings.searchEngineIndex" class="form-check-input" type="radio" name="flexRadioDefault"> <input id="searchEngineIndexNo" v-model="settings.searchEngineIndex" class="form-check-input" type="radio" name="flexRadioDefault" :value="false" required>
<label class="form-check-label" for="searchEngineIndexNo"> <label class="form-check-label" for="searchEngineIndexNo">
Discourage search engines from indexing site Discourage search engines from indexing site
</label> </label>
@ -185,7 +185,7 @@ export default {
saveGeneral() { saveGeneral() {
localStorage.timezone = this.$root.userTimezone; localStorage.timezone = this.$root.userTimezone;
toast.success("Saved.") this.saveSettings();
}, },
savePassword() { savePassword() {