Skip to content

Commit

Permalink
fix: correct way to change title and favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
RitvikSardana committed Feb 23, 2024
1 parent 701fbaa commit 2a28509
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
10 changes: 9 additions & 1 deletion education/public/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" href="/assets/education/frontend/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Frappe Education</title>
<script type="module" crossorigin src="/assets/education/frontend/assets/index.82568ddb.js"></script>
<script type="module" crossorigin src="/assets/education/frontend/assets/index.5fb23331.js"></script>
<link rel="modulepreload" href="/assets/education/frontend/assets/frappe-ui.cf491ab7.js">
<link rel="stylesheet" href="/assets/education/frontend/assets/frappe-ui.005832b0.css">
<link rel="stylesheet" href="/assets/education/frontend/assets/index.570170c2.css">
Expand All @@ -17,6 +17,14 @@

<script>
window.csrf_token = '{{ frappe.session.csrf_token }}'
window.document.title = '{{ abbr }}'
let link = document.querySelector("link[rel~='icon']");
if (!link) {
link = document.createElement('link');
link.rel = 'icon';
document.getElementsByTagName('head')[0].appendChild(link);
}
link.href = '{{ logo }}'
</script>

</body>
Expand Down
10 changes: 10 additions & 0 deletions education/www/education.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import frappe


def get_context(context):
abbr = frappe.db.get_single_value(
"Education Settings", "school_college_name_abbreviation"
)
logo = frappe.db.get_single_value("Education Settings", "school_college_logo")
context.abbr = abbr or "Frappe Education"
context.logo = logo or "/favicon.png"
8 changes: 8 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

<script>
window.csrf_token = '{{ frappe.session.csrf_token }}'
window.document.title = '{{ abbr }}'
let link = document.querySelector("link[rel~='icon']");
if (!link) {
link = document.createElement('link');
link.rel = 'icon';
document.getElementsByTagName('head')[0].appendChild(link);
}
link.href = '{{ logo }}'
</script>
<script type="module" src="/src/main.js"></script>
</body>
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,6 @@ const isSidebarCollapsed = useStorage('sidebar_is_collapsed', false)
const educationSettings = createResource({
url: 'education.education.api.get_school_abbr_logo',
auto: true,
onSuccess: (response) => {
window.document.title = response.name || "Portal"
let link = document.querySelector("link[rel~='icon']");
if (!link) {
link = document.createElement('link');
link.rel = 'icon';
document.getElementsByTagName('head')[0].appendChild(link);
}
link.href = response.logo || '/favicon.png';
}
})
</script>

0 comments on commit 2a28509

Please sign in to comment.