Skip to content

Instantly share code, notes, and snippets.

View cp-sumi-k's full-sized avatar

Sumita Canopas cp-sumi-k

View GitHub Profile
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"`
}
#! /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)
<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>
type URLSet struct {
XMLName xml.Name `xml:"urlset"`
XMLNS string `xml:"xmlns,attr"`
URL []URL `xml:"url"`
}
package jobs
import (
"db"
log "github.com/sirupsen/logrus"
)
type Job struct {
Id int `json:"id"`
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()
// 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
}
urlset := URLset{URL: sitemapUrls, XMLNS: "http://www.sitemaps.org/schemas/sitemap/0.9"}
c.Header("Content-Type", "application/xml")
c.XML(http.StatusOK, urlset)
package sitemap
import (
"encoding/xml"
"jobs"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
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 ./