This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sitemap | |
type URL struct { | |
XMLName xml.Name `xml:"url"` | |
Loc string `xml:"loc"` | |
ChangeFreq string `xml:"changefreq"` | |
LastMod string `xml:"lastmod"` | |
Priority string `xml:"priority"` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
set -e | |
BASE_URL=$1 | |
BASE_API_URL=$2 | |
API_URL="$BASE_API_URL/sitemap?baseUrl=$BASE_URL" | |
xml=$(curl -X GET --header "Accept: */*" $API_URL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | |
<url> | |
<loc>https://canopas.com</loc> | |
<changefreq>monthly</changefreq> | |
<lastmod>2022-03-01T00:00:00.000Z</lastmod> | |
<priority>1</priority> | |
</url> | |
<url> | |
<loc>https://canopas.com/jobs</loc> | |
<changefreq>monthly</changefreq> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type URLSet struct { | |
XMLName xml.Name `xml:"urlset"` | |
XMLNS string `xml:"xmlns,attr"` | |
URL []URL `xml:"url"` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jobs | |
import ( | |
"db" | |
log "github.com/sirupsen/logrus" | |
) | |
type Job struct { | |
Id int `json:"id"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jobsUrl := baseUrl + '/jobs' | |
// Init all static urls for sitemap | |
sitemapUrls := []URL{ | |
{Loc: baseUrl, Priority: `1`}, | |
{Loc: jobsUrl , Priority: `1`}, | |
} | |
// Init all dynamic urls for sitemap | |
jobs, err := GetJobs() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add changefreq and lastmod to all urls | |
year, month, _ := time.Now().Date() //get current month and year | |
lastmod := time.Date(year, month, 1, 0, 0, 0, 0, time.UTC).Format("2006-01-02T00:00:00.000Z") | |
for i := range sitemapUrls { | |
sitemapUrls[i].ChangeFreq = "monthly" | |
sitemapUrls[i].LastMod = lastmod | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
urlset := URLset{URL: sitemapUrls, XMLNS: "http://www.sitemaps.org/schemas/sitemap/0.9"} | |
c.Header("Content-Type", "application/xml") | |
c.XML(http.StatusOK, urlset) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sitemap | |
import ( | |
"encoding/xml" | |
"jobs" | |
"net/http" | |
"time" | |
"github.com/gin-gonic/gin" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:17 AS ui-build | |
WORKDIR /app | |
COPY vue-frontend/ ./ | |
RUN npm install && npm run build | |
FROM node:17 AS server-build | |
WORKDIR /root/ | |
COPY --from=ui-build /app/dist ./dist | |
COPY --from=ui-build /app/node_modules ./node_modules | |
COPY --from=ui-build /app/server.js /app/package*.json ./ |